205561c9b81649d004da48c49877b960390ac32f
[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 arr_of_J_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         arr_of_J_clz = (*env)->FindClass(env, "[J");
80         CHECK(arr_of_J_clz != NULL);
81         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_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 LDKRecipient LDKRecipient_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 Recipient.ordinal() from rust threw an exception.");
695         }
696         switch (ord) {
697                 case 0: return LDKRecipient_Node;
698                 case 1: return LDKRecipient_PhantomNode;
699         }
700         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
701         abort(); // Unreachable, but will let the compiler know we don't return here
702 }
703 static jclass Recipient_class = NULL;
704 static jfieldID Recipient_LDKRecipient_Node = NULL;
705 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
706 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
707         Recipient_class = (*env)->NewGlobalRef(env, clz);
708         CHECK(Recipient_class != NULL);
709         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
710         CHECK(Recipient_LDKRecipient_Node != NULL);
711         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
712         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
713 }
714 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
715         switch (val) {
716                 case LDKRecipient_Node:
717                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
718                 case LDKRecipient_PhantomNode:
719                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
720                 default: abort();
721         }
722 }
723
724 static inline LDKRetryableSendFailure LDKRetryableSendFailure_from_java(JNIEnv *env, jclass clz) {
725         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
726         if (UNLIKELY((*env)->ExceptionCheck(env))) {
727                 (*env)->ExceptionDescribe(env);
728                 (*env)->FatalError(env, "A call to RetryableSendFailure.ordinal() from rust threw an exception.");
729         }
730         switch (ord) {
731                 case 0: return LDKRetryableSendFailure_PaymentExpired;
732                 case 1: return LDKRetryableSendFailure_RouteNotFound;
733                 case 2: return LDKRetryableSendFailure_DuplicatePayment;
734         }
735         (*env)->FatalError(env, "A call to RetryableSendFailure.ordinal() from rust returned an invalid value.");
736         abort(); // Unreachable, but will let the compiler know we don't return here
737 }
738 static jclass RetryableSendFailure_class = NULL;
739 static jfieldID RetryableSendFailure_LDKRetryableSendFailure_PaymentExpired = NULL;
740 static jfieldID RetryableSendFailure_LDKRetryableSendFailure_RouteNotFound = NULL;
741 static jfieldID RetryableSendFailure_LDKRetryableSendFailure_DuplicatePayment = NULL;
742 JNIEXPORT void JNICALL Java_org_ldk_enums_RetryableSendFailure_init (JNIEnv *env, jclass clz) {
743         RetryableSendFailure_class = (*env)->NewGlobalRef(env, clz);
744         CHECK(RetryableSendFailure_class != NULL);
745         RetryableSendFailure_LDKRetryableSendFailure_PaymentExpired = (*env)->GetStaticFieldID(env, RetryableSendFailure_class, "LDKRetryableSendFailure_PaymentExpired", "Lorg/ldk/enums/RetryableSendFailure;");
746         CHECK(RetryableSendFailure_LDKRetryableSendFailure_PaymentExpired != NULL);
747         RetryableSendFailure_LDKRetryableSendFailure_RouteNotFound = (*env)->GetStaticFieldID(env, RetryableSendFailure_class, "LDKRetryableSendFailure_RouteNotFound", "Lorg/ldk/enums/RetryableSendFailure;");
748         CHECK(RetryableSendFailure_LDKRetryableSendFailure_RouteNotFound != NULL);
749         RetryableSendFailure_LDKRetryableSendFailure_DuplicatePayment = (*env)->GetStaticFieldID(env, RetryableSendFailure_class, "LDKRetryableSendFailure_DuplicatePayment", "Lorg/ldk/enums/RetryableSendFailure;");
750         CHECK(RetryableSendFailure_LDKRetryableSendFailure_DuplicatePayment != NULL);
751 }
752 static inline jclass LDKRetryableSendFailure_to_java(JNIEnv *env, LDKRetryableSendFailure val) {
753         switch (val) {
754                 case LDKRetryableSendFailure_PaymentExpired:
755                         return (*env)->GetStaticObjectField(env, RetryableSendFailure_class, RetryableSendFailure_LDKRetryableSendFailure_PaymentExpired);
756                 case LDKRetryableSendFailure_RouteNotFound:
757                         return (*env)->GetStaticObjectField(env, RetryableSendFailure_class, RetryableSendFailure_LDKRetryableSendFailure_RouteNotFound);
758                 case LDKRetryableSendFailure_DuplicatePayment:
759                         return (*env)->GetStaticObjectField(env, RetryableSendFailure_class, RetryableSendFailure_LDKRetryableSendFailure_DuplicatePayment);
760                 default: abort();
761         }
762 }
763
764 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
765         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
766         if (UNLIKELY((*env)->ExceptionCheck(env))) {
767                 (*env)->ExceptionDescribe(env);
768                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
769         }
770         switch (ord) {
771                 case 0: return LDKSecp256k1Error_IncorrectSignature;
772                 case 1: return LDKSecp256k1Error_InvalidMessage;
773                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
774                 case 3: return LDKSecp256k1Error_InvalidSignature;
775                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
776                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
777                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
778                 case 7: return LDKSecp256k1Error_InvalidTweak;
779                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
780                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
781                 case 10: return LDKSecp256k1Error_InvalidParityValue;
782         }
783         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
784         abort(); // Unreachable, but will let the compiler know we don't return here
785 }
786 static jclass Secp256k1Error_class = NULL;
787 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
788 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
789 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
790 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
791 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
792 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = NULL;
793 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
794 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
795 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
796 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = NULL;
797 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = NULL;
798 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
799         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
800         CHECK(Secp256k1Error_class != NULL);
801         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
802         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
803         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
804         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
805         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
806         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
807         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
808         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
809         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
810         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
811         Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSharedSecret", "Lorg/ldk/enums/Secp256k1Error;");
812         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret != NULL);
813         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
814         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
815         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
816         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
817         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
818         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
819         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKeySum", "Lorg/ldk/enums/Secp256k1Error;");
820         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum != NULL);
821         Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidParityValue", "Lorg/ldk/enums/Secp256k1Error;");
822         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidParityValue != NULL);
823 }
824 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
825         switch (val) {
826                 case LDKSecp256k1Error_IncorrectSignature:
827                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
828                 case LDKSecp256k1Error_InvalidMessage:
829                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
830                 case LDKSecp256k1Error_InvalidPublicKey:
831                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
832                 case LDKSecp256k1Error_InvalidSignature:
833                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
834                 case LDKSecp256k1Error_InvalidSecretKey:
835                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
836                 case LDKSecp256k1Error_InvalidSharedSecret:
837                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret);
838                 case LDKSecp256k1Error_InvalidRecoveryId:
839                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
840                 case LDKSecp256k1Error_InvalidTweak:
841                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
842                 case LDKSecp256k1Error_NotEnoughMemory:
843                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
844                 case LDKSecp256k1Error_InvalidPublicKeySum:
845                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum);
846                 case LDKSecp256k1Error_InvalidParityValue:
847                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidParityValue);
848                 default: abort();
849         }
850 }
851
852 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
853         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
854         if (UNLIKELY((*env)->ExceptionCheck(env))) {
855                 (*env)->ExceptionDescribe(env);
856                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
857         }
858         switch (ord) {
859                 case 0: return LDKSemanticError_NoPaymentHash;
860                 case 1: return LDKSemanticError_MultiplePaymentHashes;
861                 case 2: return LDKSemanticError_NoDescription;
862                 case 3: return LDKSemanticError_MultipleDescriptions;
863                 case 4: return LDKSemanticError_NoPaymentSecret;
864                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
865                 case 6: return LDKSemanticError_InvalidFeatures;
866                 case 7: return LDKSemanticError_InvalidRecoveryId;
867                 case 8: return LDKSemanticError_InvalidSignature;
868                 case 9: return LDKSemanticError_ImpreciseAmount;
869         }
870         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
871         abort(); // Unreachable, but will let the compiler know we don't return here
872 }
873 static jclass SemanticError_class = NULL;
874 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
875 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
876 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
877 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
878 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
879 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
880 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
881 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
882 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
883 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
884 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
885         SemanticError_class = (*env)->NewGlobalRef(env, clz);
886         CHECK(SemanticError_class != NULL);
887         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
888         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
889         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
890         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
891         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
892         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
893         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
894         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
895         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
896         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
897         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
898         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
899         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
900         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
901         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
902         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
903         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
904         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
905         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
906         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
907 }
908 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
909         switch (val) {
910                 case LDKSemanticError_NoPaymentHash:
911                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
912                 case LDKSemanticError_MultiplePaymentHashes:
913                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
914                 case LDKSemanticError_NoDescription:
915                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
916                 case LDKSemanticError_MultipleDescriptions:
917                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
918                 case LDKSemanticError_NoPaymentSecret:
919                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
920                 case LDKSemanticError_MultiplePaymentSecrets:
921                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
922                 case LDKSemanticError_InvalidFeatures:
923                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
924                 case LDKSemanticError_InvalidRecoveryId:
925                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
926                 case LDKSemanticError_InvalidSignature:
927                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
928                 case LDKSemanticError_ImpreciseAmount:
929                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
930                 default: abort();
931         }
932 }
933
934 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
935         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
936         if (UNLIKELY((*env)->ExceptionCheck(env))) {
937                 (*env)->ExceptionDescribe(env);
938                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
939         }
940         switch (ord) {
941                 case 0: return LDKSiPrefix_Milli;
942                 case 1: return LDKSiPrefix_Micro;
943                 case 2: return LDKSiPrefix_Nano;
944                 case 3: return LDKSiPrefix_Pico;
945         }
946         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
947         abort(); // Unreachable, but will let the compiler know we don't return here
948 }
949 static jclass SiPrefix_class = NULL;
950 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
951 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
952 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
953 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
954 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
955         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
956         CHECK(SiPrefix_class != NULL);
957         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
958         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
959         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
960         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
961         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
962         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
963         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
964         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
965 }
966 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
967         switch (val) {
968                 case LDKSiPrefix_Milli:
969                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
970                 case LDKSiPrefix_Micro:
971                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
972                 case LDKSiPrefix_Nano:
973                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
974                 case LDKSiPrefix_Pico:
975                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
976                 default: abort();
977         }
978 }
979
980 static inline LDKUtxoLookupError LDKUtxoLookupError_from_java(JNIEnv *env, jclass clz) {
981         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
982         if (UNLIKELY((*env)->ExceptionCheck(env))) {
983                 (*env)->ExceptionDescribe(env);
984                 (*env)->FatalError(env, "A call to UtxoLookupError.ordinal() from rust threw an exception.");
985         }
986         switch (ord) {
987                 case 0: return LDKUtxoLookupError_UnknownChain;
988                 case 1: return LDKUtxoLookupError_UnknownTx;
989         }
990         (*env)->FatalError(env, "A call to UtxoLookupError.ordinal() from rust returned an invalid value.");
991         abort(); // Unreachable, but will let the compiler know we don't return here
992 }
993 static jclass UtxoLookupError_class = NULL;
994 static jfieldID UtxoLookupError_LDKUtxoLookupError_UnknownChain = NULL;
995 static jfieldID UtxoLookupError_LDKUtxoLookupError_UnknownTx = NULL;
996 JNIEXPORT void JNICALL Java_org_ldk_enums_UtxoLookupError_init (JNIEnv *env, jclass clz) {
997         UtxoLookupError_class = (*env)->NewGlobalRef(env, clz);
998         CHECK(UtxoLookupError_class != NULL);
999         UtxoLookupError_LDKUtxoLookupError_UnknownChain = (*env)->GetStaticFieldID(env, UtxoLookupError_class, "LDKUtxoLookupError_UnknownChain", "Lorg/ldk/enums/UtxoLookupError;");
1000         CHECK(UtxoLookupError_LDKUtxoLookupError_UnknownChain != NULL);
1001         UtxoLookupError_LDKUtxoLookupError_UnknownTx = (*env)->GetStaticFieldID(env, UtxoLookupError_class, "LDKUtxoLookupError_UnknownTx", "Lorg/ldk/enums/UtxoLookupError;");
1002         CHECK(UtxoLookupError_LDKUtxoLookupError_UnknownTx != NULL);
1003 }
1004 static inline jclass LDKUtxoLookupError_to_java(JNIEnv *env, LDKUtxoLookupError val) {
1005         switch (val) {
1006                 case LDKUtxoLookupError_UnknownChain:
1007                         return (*env)->GetStaticObjectField(env, UtxoLookupError_class, UtxoLookupError_LDKUtxoLookupError_UnknownChain);
1008                 case LDKUtxoLookupError_UnknownTx:
1009                         return (*env)->GetStaticObjectField(env, UtxoLookupError_class, UtxoLookupError_LDKUtxoLookupError_UnknownTx);
1010                 default: abort();
1011         }
1012 }
1013
1014 struct LDKThirtyTwoBytes BigEndianScalar_get_bytes (struct LDKBigEndianScalar* thing) {
1015         LDKThirtyTwoBytes ret = { .data = *thing->big_endian_bytes };
1016         return ret;
1017 }
1018 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1get_1bytes(JNIEnv *env, jclass clz, int64_t thing) {
1019         LDKBigEndianScalar* thing_conv = (LDKBigEndianScalar*)untag_ptr(thing);
1020         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1021         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BigEndianScalar_get_bytes(thing_conv).data);
1022         return ret_arr;
1023 }
1024
1025 static void BigEndianScalar_free (struct LDKBigEndianScalar thing) {}
1026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1free(JNIEnv *env, jclass clz, int64_t thing) {
1027         if (!ptr_is_owned(thing)) return;
1028         void* thing_ptr = untag_ptr(thing);
1029         CHECK_ACCESS(thing_ptr);
1030         LDKBigEndianScalar thing_conv = *(LDKBigEndianScalar*)(thing_ptr);
1031         FREE(untag_ptr(thing));
1032         BigEndianScalar_free(thing_conv);
1033 }
1034
1035 static jclass LDKBech32Error_MissingSeparator_class = NULL;
1036 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
1037 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
1038 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
1039 static jclass LDKBech32Error_InvalidLength_class = NULL;
1040 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
1041 static jclass LDKBech32Error_InvalidChar_class = NULL;
1042 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
1043 static jclass LDKBech32Error_InvalidData_class = NULL;
1044 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
1045 static jclass LDKBech32Error_InvalidPadding_class = NULL;
1046 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
1047 static jclass LDKBech32Error_MixedCase_class = NULL;
1048 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
1049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
1050         LDKBech32Error_MissingSeparator_class =
1051                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
1052         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
1053         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
1054         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
1055         LDKBech32Error_InvalidChecksum_class =
1056                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
1057         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
1058         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
1059         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
1060         LDKBech32Error_InvalidLength_class =
1061                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
1062         CHECK(LDKBech32Error_InvalidLength_class != NULL);
1063         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
1064         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
1065         LDKBech32Error_InvalidChar_class =
1066                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
1067         CHECK(LDKBech32Error_InvalidChar_class != NULL);
1068         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
1069         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
1070         LDKBech32Error_InvalidData_class =
1071                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
1072         CHECK(LDKBech32Error_InvalidData_class != NULL);
1073         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
1074         CHECK(LDKBech32Error_InvalidData_meth != NULL);
1075         LDKBech32Error_InvalidPadding_class =
1076                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
1077         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
1078         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
1079         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
1080         LDKBech32Error_MixedCase_class =
1081                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
1082         CHECK(LDKBech32Error_MixedCase_class != NULL);
1083         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
1084         CHECK(LDKBech32Error_MixedCase_meth != NULL);
1085 }
1086 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1087         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
1088         switch(obj->tag) {
1089                 case LDKBech32Error_MissingSeparator: {
1090                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
1091                 }
1092                 case LDKBech32Error_InvalidChecksum: {
1093                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
1094                 }
1095                 case LDKBech32Error_InvalidLength: {
1096                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
1097                 }
1098                 case LDKBech32Error_InvalidChar: {
1099                         int32_t invalid_char_conv = obj->invalid_char;
1100                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
1101                 }
1102                 case LDKBech32Error_InvalidData: {
1103                         int8_t invalid_data_conv = obj->invalid_data;
1104                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
1105                 }
1106                 case LDKBech32Error_InvalidPadding: {
1107                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
1108                 }
1109                 case LDKBech32Error_MixedCase: {
1110                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
1111                 }
1112                 default: abort();
1113         }
1114 }
1115 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
1116         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
1117         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
1118         return ret;
1119 }
1120 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) {
1121         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1122         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
1123         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1124         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1125         CVec_u8Z_free(ret_var);
1126         return ret_arr;
1127 }
1128
1129 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) {
1130         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1131         int64_t ret_conv = TxOut_get_value(thing_conv);
1132         return ret_conv;
1133 }
1134
1135 static jclass LDKAPIError_APIMisuseError_class = NULL;
1136 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
1137 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
1138 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
1139 static jclass LDKAPIError_InvalidRoute_class = NULL;
1140 static jmethodID LDKAPIError_InvalidRoute_meth = NULL;
1141 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
1142 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
1143 static jclass LDKAPIError_MonitorUpdateInProgress_class = NULL;
1144 static jmethodID LDKAPIError_MonitorUpdateInProgress_meth = NULL;
1145 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
1146 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
1147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
1148         LDKAPIError_APIMisuseError_class =
1149                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
1150         CHECK(LDKAPIError_APIMisuseError_class != NULL);
1151         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
1152         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
1153         LDKAPIError_FeeRateTooHigh_class =
1154                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
1155         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
1156         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
1157         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
1158         LDKAPIError_InvalidRoute_class =
1159                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$InvalidRoute"));
1160         CHECK(LDKAPIError_InvalidRoute_class != NULL);
1161         LDKAPIError_InvalidRoute_meth = (*env)->GetMethodID(env, LDKAPIError_InvalidRoute_class, "<init>", "(Ljava/lang/String;)V");
1162         CHECK(LDKAPIError_InvalidRoute_meth != NULL);
1163         LDKAPIError_ChannelUnavailable_class =
1164                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
1165         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
1166         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
1167         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
1168         LDKAPIError_MonitorUpdateInProgress_class =
1169                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateInProgress"));
1170         CHECK(LDKAPIError_MonitorUpdateInProgress_class != NULL);
1171         LDKAPIError_MonitorUpdateInProgress_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateInProgress_class, "<init>", "()V");
1172         CHECK(LDKAPIError_MonitorUpdateInProgress_meth != NULL);
1173         LDKAPIError_IncompatibleShutdownScript_class =
1174                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
1175         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
1176         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
1177         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
1178 }
1179 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1180         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1181         switch(obj->tag) {
1182                 case LDKAPIError_APIMisuseError: {
1183                         LDKStr err_str = obj->api_misuse_error.err;
1184                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1185                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
1186                 }
1187                 case LDKAPIError_FeeRateTooHigh: {
1188                         LDKStr err_str = obj->fee_rate_too_high.err;
1189                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1190                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
1191                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
1192                 }
1193                 case LDKAPIError_InvalidRoute: {
1194                         LDKStr err_str = obj->invalid_route.err;
1195                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1196                         return (*env)->NewObject(env, LDKAPIError_InvalidRoute_class, LDKAPIError_InvalidRoute_meth, err_conv);
1197                 }
1198                 case LDKAPIError_ChannelUnavailable: {
1199                         LDKStr err_str = obj->channel_unavailable.err;
1200                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1201                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
1202                 }
1203                 case LDKAPIError_MonitorUpdateInProgress: {
1204                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateInProgress_class, LDKAPIError_MonitorUpdateInProgress_meth);
1205                 }
1206                 case LDKAPIError_IncompatibleShutdownScript: {
1207                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
1208                         int64_t script_ref = 0;
1209                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
1210                         script_ref = tag_ptr(script_var.inner, false);
1211                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
1212                 }
1213                 default: abort();
1214         }
1215 }
1216 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
1217 CHECK(owner->result_ok);
1218         return *owner->contents.result;
1219 }
1220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1221         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
1222         CResult_NoneAPIErrorZ_get_ok(owner_conv);
1223 }
1224
1225 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
1226 CHECK(!owner->result_ok);
1227         return APIError_clone(&*owner->contents.err);
1228 }
1229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1230         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
1231         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
1232         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
1233         int64_t ret_ref = tag_ptr(ret_copy, true);
1234         return ret_ref;
1235 }
1236
1237 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
1238         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
1239         for (size_t i = 0; i < ret.datalen; i++) {
1240                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
1241         }
1242         return ret;
1243 }
1244 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
1245         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
1246         for (size_t i = 0; i < ret.datalen; i++) {
1247                 ret.data[i] = APIError_clone(&orig->data[i]);
1248         }
1249         return ret;
1250 }
1251 static jclass LDKCOption_HTLCClaimZ_Some_class = NULL;
1252 static jmethodID LDKCOption_HTLCClaimZ_Some_meth = NULL;
1253 static jclass LDKCOption_HTLCClaimZ_None_class = NULL;
1254 static jmethodID LDKCOption_HTLCClaimZ_None_meth = NULL;
1255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCClaimZ_init (JNIEnv *env, jclass clz) {
1256         LDKCOption_HTLCClaimZ_Some_class =
1257                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCClaimZ$Some"));
1258         CHECK(LDKCOption_HTLCClaimZ_Some_class != NULL);
1259         LDKCOption_HTLCClaimZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCClaimZ_Some_class, "<init>", "(Lorg/ldk/enums/HTLCClaim;)V");
1260         CHECK(LDKCOption_HTLCClaimZ_Some_meth != NULL);
1261         LDKCOption_HTLCClaimZ_None_class =
1262                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCClaimZ$None"));
1263         CHECK(LDKCOption_HTLCClaimZ_None_class != NULL);
1264         LDKCOption_HTLCClaimZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCClaimZ_None_class, "<init>", "()V");
1265         CHECK(LDKCOption_HTLCClaimZ_None_meth != NULL);
1266 }
1267 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCClaimZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1268         LDKCOption_HTLCClaimZ *obj = (LDKCOption_HTLCClaimZ*)untag_ptr(ptr);
1269         switch(obj->tag) {
1270                 case LDKCOption_HTLCClaimZ_Some: {
1271                         jclass some_conv = LDKHTLCClaim_to_java(env, obj->some);
1272                         return (*env)->NewObject(env, LDKCOption_HTLCClaimZ_Some_class, LDKCOption_HTLCClaimZ_Some_meth, some_conv);
1273                 }
1274                 case LDKCOption_HTLCClaimZ_None: {
1275                         return (*env)->NewObject(env, LDKCOption_HTLCClaimZ_None_class, LDKCOption_HTLCClaimZ_None_meth);
1276                 }
1277                 default: abort();
1278         }
1279 }
1280 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1281 CHECK(owner->result_ok);
1282         return *owner->contents.result;
1283 }
1284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1285         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1286         CResult_NoneNoneZ_get_ok(owner_conv);
1287 }
1288
1289 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1290 CHECK(!owner->result_ok);
1291         return *owner->contents.err;
1292 }
1293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1294         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1295         CResult_NoneNoneZ_get_err(owner_conv);
1296 }
1297
1298 static jclass LDKDecodeError_UnknownVersion_class = NULL;
1299 static jmethodID LDKDecodeError_UnknownVersion_meth = NULL;
1300 static jclass LDKDecodeError_UnknownRequiredFeature_class = NULL;
1301 static jmethodID LDKDecodeError_UnknownRequiredFeature_meth = NULL;
1302 static jclass LDKDecodeError_InvalidValue_class = NULL;
1303 static jmethodID LDKDecodeError_InvalidValue_meth = NULL;
1304 static jclass LDKDecodeError_ShortRead_class = NULL;
1305 static jmethodID LDKDecodeError_ShortRead_meth = NULL;
1306 static jclass LDKDecodeError_BadLengthDescriptor_class = NULL;
1307 static jmethodID LDKDecodeError_BadLengthDescriptor_meth = NULL;
1308 static jclass LDKDecodeError_Io_class = NULL;
1309 static jmethodID LDKDecodeError_Io_meth = NULL;
1310 static jclass LDKDecodeError_UnsupportedCompression_class = NULL;
1311 static jmethodID LDKDecodeError_UnsupportedCompression_meth = NULL;
1312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKDecodeError_init (JNIEnv *env, jclass clz) {
1313         LDKDecodeError_UnknownVersion_class =
1314                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnknownVersion"));
1315         CHECK(LDKDecodeError_UnknownVersion_class != NULL);
1316         LDKDecodeError_UnknownVersion_meth = (*env)->GetMethodID(env, LDKDecodeError_UnknownVersion_class, "<init>", "()V");
1317         CHECK(LDKDecodeError_UnknownVersion_meth != NULL);
1318         LDKDecodeError_UnknownRequiredFeature_class =
1319                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnknownRequiredFeature"));
1320         CHECK(LDKDecodeError_UnknownRequiredFeature_class != NULL);
1321         LDKDecodeError_UnknownRequiredFeature_meth = (*env)->GetMethodID(env, LDKDecodeError_UnknownRequiredFeature_class, "<init>", "()V");
1322         CHECK(LDKDecodeError_UnknownRequiredFeature_meth != NULL);
1323         LDKDecodeError_InvalidValue_class =
1324                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$InvalidValue"));
1325         CHECK(LDKDecodeError_InvalidValue_class != NULL);
1326         LDKDecodeError_InvalidValue_meth = (*env)->GetMethodID(env, LDKDecodeError_InvalidValue_class, "<init>", "()V");
1327         CHECK(LDKDecodeError_InvalidValue_meth != NULL);
1328         LDKDecodeError_ShortRead_class =
1329                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$ShortRead"));
1330         CHECK(LDKDecodeError_ShortRead_class != NULL);
1331         LDKDecodeError_ShortRead_meth = (*env)->GetMethodID(env, LDKDecodeError_ShortRead_class, "<init>", "()V");
1332         CHECK(LDKDecodeError_ShortRead_meth != NULL);
1333         LDKDecodeError_BadLengthDescriptor_class =
1334                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$BadLengthDescriptor"));
1335         CHECK(LDKDecodeError_BadLengthDescriptor_class != NULL);
1336         LDKDecodeError_BadLengthDescriptor_meth = (*env)->GetMethodID(env, LDKDecodeError_BadLengthDescriptor_class, "<init>", "()V");
1337         CHECK(LDKDecodeError_BadLengthDescriptor_meth != NULL);
1338         LDKDecodeError_Io_class =
1339                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$Io"));
1340         CHECK(LDKDecodeError_Io_class != NULL);
1341         LDKDecodeError_Io_meth = (*env)->GetMethodID(env, LDKDecodeError_Io_class, "<init>", "(Lorg/ldk/enums/IOError;)V");
1342         CHECK(LDKDecodeError_Io_meth != NULL);
1343         LDKDecodeError_UnsupportedCompression_class =
1344                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnsupportedCompression"));
1345         CHECK(LDKDecodeError_UnsupportedCompression_class != NULL);
1346         LDKDecodeError_UnsupportedCompression_meth = (*env)->GetMethodID(env, LDKDecodeError_UnsupportedCompression_class, "<init>", "()V");
1347         CHECK(LDKDecodeError_UnsupportedCompression_meth != NULL);
1348 }
1349 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKDecodeError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1350         LDKDecodeError *obj = (LDKDecodeError*)untag_ptr(ptr);
1351         switch(obj->tag) {
1352                 case LDKDecodeError_UnknownVersion: {
1353                         return (*env)->NewObject(env, LDKDecodeError_UnknownVersion_class, LDKDecodeError_UnknownVersion_meth);
1354                 }
1355                 case LDKDecodeError_UnknownRequiredFeature: {
1356                         return (*env)->NewObject(env, LDKDecodeError_UnknownRequiredFeature_class, LDKDecodeError_UnknownRequiredFeature_meth);
1357                 }
1358                 case LDKDecodeError_InvalidValue: {
1359                         return (*env)->NewObject(env, LDKDecodeError_InvalidValue_class, LDKDecodeError_InvalidValue_meth);
1360                 }
1361                 case LDKDecodeError_ShortRead: {
1362                         return (*env)->NewObject(env, LDKDecodeError_ShortRead_class, LDKDecodeError_ShortRead_meth);
1363                 }
1364                 case LDKDecodeError_BadLengthDescriptor: {
1365                         return (*env)->NewObject(env, LDKDecodeError_BadLengthDescriptor_class, LDKDecodeError_BadLengthDescriptor_meth);
1366                 }
1367                 case LDKDecodeError_Io: {
1368                         jclass io_conv = LDKIOError_to_java(env, obj->io);
1369                         return (*env)->NewObject(env, LDKDecodeError_Io_class, LDKDecodeError_Io_meth, io_conv);
1370                 }
1371                 case LDKDecodeError_UnsupportedCompression: {
1372                         return (*env)->NewObject(env, LDKDecodeError_UnsupportedCompression_class, LDKDecodeError_UnsupportedCompression_meth);
1373                 }
1374                 default: abort();
1375         }
1376 }
1377 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1378         LDKCounterpartyCommitmentSecrets ret = *owner->contents.result;
1379         ret.is_owned = false;
1380         return ret;
1381 }
1382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1383         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1384         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
1385         int64_t ret_ref = 0;
1386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1387         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1388         return ret_ref;
1389 }
1390
1391 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1392 CHECK(!owner->result_ok);
1393         return DecodeError_clone(&*owner->contents.err);
1394 }
1395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1396         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1397         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1398         *ret_copy = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1399         int64_t ret_ref = tag_ptr(ret_copy, true);
1400         return ret_ref;
1401 }
1402
1403 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1404         LDKTxCreationKeys ret = *owner->contents.result;
1405         ret.is_owned = false;
1406         return ret;
1407 }
1408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1409         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1410         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1411         int64_t ret_ref = 0;
1412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1413         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1414         return ret_ref;
1415 }
1416
1417 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1418 CHECK(!owner->result_ok);
1419         return DecodeError_clone(&*owner->contents.err);
1420 }
1421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1422         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1423         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1424         *ret_copy = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1425         int64_t ret_ref = tag_ptr(ret_copy, true);
1426         return ret_ref;
1427 }
1428
1429 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1430         LDKChannelPublicKeys ret = *owner->contents.result;
1431         ret.is_owned = false;
1432         return ret;
1433 }
1434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1435         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1436         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1437         int64_t ret_ref = 0;
1438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1439         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1440         return ret_ref;
1441 }
1442
1443 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1444 CHECK(!owner->result_ok);
1445         return DecodeError_clone(&*owner->contents.err);
1446 }
1447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1448         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1449         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1450         *ret_copy = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1451         int64_t ret_ref = tag_ptr(ret_copy, true);
1452         return ret_ref;
1453 }
1454
1455 static jclass LDKCOption_u32Z_Some_class = NULL;
1456 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1457 static jclass LDKCOption_u32Z_None_class = NULL;
1458 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1460         LDKCOption_u32Z_Some_class =
1461                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1462         CHECK(LDKCOption_u32Z_Some_class != NULL);
1463         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1464         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1465         LDKCOption_u32Z_None_class =
1466                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1467         CHECK(LDKCOption_u32Z_None_class != NULL);
1468         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1469         CHECK(LDKCOption_u32Z_None_meth != NULL);
1470 }
1471 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1472         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)untag_ptr(ptr);
1473         switch(obj->tag) {
1474                 case LDKCOption_u32Z_Some: {
1475                         int32_t some_conv = obj->some;
1476                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1477                 }
1478                 case LDKCOption_u32Z_None: {
1479                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1480                 }
1481                 default: abort();
1482         }
1483 }
1484 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1485         LDKHTLCOutputInCommitment ret = *owner->contents.result;
1486         ret.is_owned = false;
1487         return ret;
1488 }
1489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1490         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1491         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_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_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *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_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1503         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1504         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1505         *ret_copy = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1506         int64_t ret_ref = tag_ptr(ret_copy, true);
1507         return ret_ref;
1508 }
1509
1510 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1511         LDKCounterpartyChannelTransactionParameters ret = *owner->contents.result;
1512         ret.is_owned = false;
1513         return ret;
1514 }
1515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1516         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1517         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1518         int64_t ret_ref = 0;
1519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1520         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1521         return ret_ref;
1522 }
1523
1524 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1525 CHECK(!owner->result_ok);
1526         return DecodeError_clone(&*owner->contents.err);
1527 }
1528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1529         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1530         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1531         *ret_copy = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1532         int64_t ret_ref = tag_ptr(ret_copy, true);
1533         return ret_ref;
1534 }
1535
1536 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1537         LDKChannelTransactionParameters ret = *owner->contents.result;
1538         ret.is_owned = false;
1539         return ret;
1540 }
1541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1542         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1543         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1544         int64_t ret_ref = 0;
1545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1546         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1547         return ret_ref;
1548 }
1549
1550 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1551 CHECK(!owner->result_ok);
1552         return DecodeError_clone(&*owner->contents.err);
1553 }
1554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1555         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1556         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1557         *ret_copy = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1558         int64_t ret_ref = tag_ptr(ret_copy, true);
1559         return ret_ref;
1560 }
1561
1562 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1563         LDKHolderCommitmentTransaction ret = *owner->contents.result;
1564         ret.is_owned = false;
1565         return ret;
1566 }
1567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1568         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1569         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1570         int64_t ret_ref = 0;
1571         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1572         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1573         return ret_ref;
1574 }
1575
1576 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1577 CHECK(!owner->result_ok);
1578         return DecodeError_clone(&*owner->contents.err);
1579 }
1580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1581         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1582         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1583         *ret_copy = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1584         int64_t ret_ref = tag_ptr(ret_copy, true);
1585         return ret_ref;
1586 }
1587
1588 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1589         LDKBuiltCommitmentTransaction ret = *owner->contents.result;
1590         ret.is_owned = false;
1591         return ret;
1592 }
1593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1594         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1595         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1596         int64_t ret_ref = 0;
1597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1598         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1599         return ret_ref;
1600 }
1601
1602 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1603 CHECK(!owner->result_ok);
1604         return DecodeError_clone(&*owner->contents.err);
1605 }
1606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1607         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1608         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1609         *ret_copy = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1610         int64_t ret_ref = tag_ptr(ret_copy, true);
1611         return ret_ref;
1612 }
1613
1614 static inline struct LDKTrustedClosingTransaction CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1615         LDKTrustedClosingTransaction ret = *owner->contents.result;
1616         ret.is_owned = false;
1617         return ret;
1618 }
1619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1620         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1621         LDKTrustedClosingTransaction ret_var = CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1622         int64_t ret_ref = 0;
1623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1624         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1625         return ret_ref;
1626 }
1627
1628 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1629 CHECK(!owner->result_ok);
1630         return *owner->contents.err;
1631 }
1632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1633         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1634         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1635 }
1636
1637 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1638         LDKCommitmentTransaction ret = *owner->contents.result;
1639         ret.is_owned = false;
1640         return ret;
1641 }
1642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1643         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1644         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1645         int64_t ret_ref = 0;
1646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1647         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1648         return ret_ref;
1649 }
1650
1651 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1652 CHECK(!owner->result_ok);
1653         return DecodeError_clone(&*owner->contents.err);
1654 }
1655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1656         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1657         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1658         *ret_copy = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1659         int64_t ret_ref = tag_ptr(ret_copy, true);
1660         return ret_ref;
1661 }
1662
1663 static inline struct LDKTrustedCommitmentTransaction CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1664         LDKTrustedCommitmentTransaction ret = *owner->contents.result;
1665         ret.is_owned = false;
1666         return ret;
1667 }
1668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1669         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1670         LDKTrustedCommitmentTransaction ret_var = CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1671         int64_t ret_ref = 0;
1672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1673         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1674         return ret_ref;
1675 }
1676
1677 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1678 CHECK(!owner->result_ok);
1679         return *owner->contents.err;
1680 }
1681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1682         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1683         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1684 }
1685
1686 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1687 CHECK(owner->result_ok);
1688         return *owner->contents.result;
1689 }
1690 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1691         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1692         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1693         jobjectArray ret_arr = NULL;
1694         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1695         ;
1696         for (size_t i = 0; i < ret_var.datalen; i++) {
1697                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1698                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1699                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1700         }
1701         
1702         return ret_arr;
1703 }
1704
1705 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1706 CHECK(!owner->result_ok);
1707         return *owner->contents.err;
1708 }
1709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1710         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1711         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1712 }
1713
1714 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1715         LDKShutdownScript ret = *owner->contents.result;
1716         ret.is_owned = false;
1717         return ret;
1718 }
1719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1720         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1721         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1722         int64_t ret_ref = 0;
1723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1724         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1725         return ret_ref;
1726 }
1727
1728 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1729 CHECK(!owner->result_ok);
1730         return DecodeError_clone(&*owner->contents.err);
1731 }
1732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1733         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1734         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1735         *ret_copy = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1736         int64_t ret_ref = tag_ptr(ret_copy, true);
1737         return ret_ref;
1738 }
1739
1740 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1741         LDKShutdownScript ret = *owner->contents.result;
1742         ret.is_owned = false;
1743         return ret;
1744 }
1745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1746         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1747         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1748         int64_t ret_ref = 0;
1749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1750         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1751         return ret_ref;
1752 }
1753
1754 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1755         LDKInvalidShutdownScript ret = *owner->contents.err;
1756         ret.is_owned = false;
1757         return ret;
1758 }
1759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1760         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1761         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1762         int64_t ret_ref = 0;
1763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1764         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1765         return ret_ref;
1766 }
1767
1768 static inline struct LDKBlindedPath CResult_BlindedPathNoneZ_get_ok(LDKCResult_BlindedPathNoneZ *NONNULL_PTR owner){
1769         LDKBlindedPath ret = *owner->contents.result;
1770         ret.is_owned = false;
1771         return ret;
1772 }
1773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1774         LDKCResult_BlindedPathNoneZ* owner_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(owner);
1775         LDKBlindedPath ret_var = CResult_BlindedPathNoneZ_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 void CResult_BlindedPathNoneZ_get_err(LDKCResult_BlindedPathNoneZ *NONNULL_PTR owner){
1783 CHECK(!owner->result_ok);
1784         return *owner->contents.err;
1785 }
1786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1787         LDKCResult_BlindedPathNoneZ* owner_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(owner);
1788         CResult_BlindedPathNoneZ_get_err(owner_conv);
1789 }
1790
1791 static inline struct LDKBlindedPath CResult_BlindedPathDecodeErrorZ_get_ok(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR owner){
1792         LDKBlindedPath ret = *owner->contents.result;
1793         ret.is_owned = false;
1794         return ret;
1795 }
1796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1797         LDKCResult_BlindedPathDecodeErrorZ* owner_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(owner);
1798         LDKBlindedPath ret_var = CResult_BlindedPathDecodeErrorZ_get_ok(owner_conv);
1799         int64_t ret_ref = 0;
1800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1801         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1802         return ret_ref;
1803 }
1804
1805 static inline struct LDKDecodeError CResult_BlindedPathDecodeErrorZ_get_err(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR owner){
1806 CHECK(!owner->result_ok);
1807         return DecodeError_clone(&*owner->contents.err);
1808 }
1809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1810         LDKCResult_BlindedPathDecodeErrorZ* owner_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(owner);
1811         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1812         *ret_copy = CResult_BlindedPathDecodeErrorZ_get_err(owner_conv);
1813         int64_t ret_ref = tag_ptr(ret_copy, true);
1814         return ret_ref;
1815 }
1816
1817 static inline struct LDKBlindedHop CResult_BlindedHopDecodeErrorZ_get_ok(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
1818         LDKBlindedHop ret = *owner->contents.result;
1819         ret.is_owned = false;
1820         return ret;
1821 }
1822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1823         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
1824         LDKBlindedHop ret_var = CResult_BlindedHopDecodeErrorZ_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_BlindedHopDecodeErrorZ_get_err(LDKCResult_BlindedHopDecodeErrorZ *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_1BlindedHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1836         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
1837         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1838         *ret_copy = CResult_BlindedHopDecodeErrorZ_get_err(owner_conv);
1839         int64_t ret_ref = tag_ptr(ret_copy, true);
1840         return ret_ref;
1841 }
1842
1843 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1844         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1845         for (size_t i = 0; i < ret.datalen; i++) {
1846                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1847         }
1848         return ret;
1849 }
1850 typedef struct LDKScore_JCalls {
1851         atomic_size_t refcnt;
1852         JavaVM *vm;
1853         jweak o;
1854         jmethodID channel_penalty_msat_meth;
1855         jmethodID payment_path_failed_meth;
1856         jmethodID payment_path_successful_meth;
1857         jmethodID probe_failed_meth;
1858         jmethodID probe_successful_meth;
1859         jmethodID write_meth;
1860 } LDKScore_JCalls;
1861 static void LDKScore_JCalls_free(void* this_arg) {
1862         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1863         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1864                 JNIEnv *env;
1865                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1866                 if (get_jenv_res == JNI_EDETACHED) {
1867                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1868                 } else {
1869                         DO_ASSERT(get_jenv_res == JNI_OK);
1870                 }
1871                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1872                 if (get_jenv_res == JNI_EDETACHED) {
1873                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1874                 }
1875                 FREE(j_calls);
1876         }
1877 }
1878 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
1879         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1880         JNIEnv *env;
1881         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1882         if (get_jenv_res == JNI_EDETACHED) {
1883                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1884         } else {
1885                 DO_ASSERT(get_jenv_res == JNI_OK);
1886         }
1887         int64_t short_channel_id_conv = short_channel_id;
1888         LDKNodeId source_var = *source;
1889         int64_t source_ref = 0;
1890         source_var = NodeId_clone(&source_var);
1891         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
1892         source_ref = tag_ptr(source_var.inner, source_var.is_owned);
1893         LDKNodeId target_var = *target;
1894         int64_t target_ref = 0;
1895         target_var = NodeId_clone(&target_var);
1896         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
1897         target_ref = tag_ptr(target_var.inner, target_var.is_owned);
1898         LDKChannelUsage usage_var = usage;
1899         int64_t usage_ref = 0;
1900         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
1901         usage_ref = tag_ptr(usage_var.inner, usage_var.is_owned);
1902         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1903         CHECK(obj != NULL);
1904         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, source_ref, target_ref, usage_ref);
1905         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1906                 (*env)->ExceptionDescribe(env);
1907                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
1908         }
1909         if (get_jenv_res == JNI_EDETACHED) {
1910                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1911         }
1912         return ret;
1913 }
1914 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
1915         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1916         JNIEnv *env;
1917         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1918         if (get_jenv_res == JNI_EDETACHED) {
1919                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1920         } else {
1921                 DO_ASSERT(get_jenv_res == JNI_OK);
1922         }
1923         LDKCVec_RouteHopZ path_var = path;
1924         int64_tArray path_arr = NULL;
1925         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1926         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1927         for (size_t k = 0; k < path_var.datalen; k++) {
1928                 LDKRouteHop path_conv_10_var = path_var.data[k];
1929                 int64_t path_conv_10_ref = 0;
1930                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1931                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1932                 path_arr_ptr[k] = path_conv_10_ref;
1933         }
1934         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1935         FREE(path_var.data);
1936         int64_t short_channel_id_conv = short_channel_id;
1937         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1938         CHECK(obj != NULL);
1939         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id_conv);
1940         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1941                 (*env)->ExceptionDescribe(env);
1942                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
1943         }
1944         if (get_jenv_res == JNI_EDETACHED) {
1945                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1946         }
1947 }
1948 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
1949         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1950         JNIEnv *env;
1951         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1952         if (get_jenv_res == JNI_EDETACHED) {
1953                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1954         } else {
1955                 DO_ASSERT(get_jenv_res == JNI_OK);
1956         }
1957         LDKCVec_RouteHopZ path_var = path;
1958         int64_tArray path_arr = NULL;
1959         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1960         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1961         for (size_t k = 0; k < path_var.datalen; k++) {
1962                 LDKRouteHop path_conv_10_var = path_var.data[k];
1963                 int64_t path_conv_10_ref = 0;
1964                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1965                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1966                 path_arr_ptr[k] = path_conv_10_ref;
1967         }
1968         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1969         FREE(path_var.data);
1970         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1971         CHECK(obj != NULL);
1972         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
1973         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1974                 (*env)->ExceptionDescribe(env);
1975                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
1976         }
1977         if (get_jenv_res == JNI_EDETACHED) {
1978                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1979         }
1980 }
1981 void probe_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
1982         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1983         JNIEnv *env;
1984         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1985         if (get_jenv_res == JNI_EDETACHED) {
1986                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1987         } else {
1988                 DO_ASSERT(get_jenv_res == JNI_OK);
1989         }
1990         LDKCVec_RouteHopZ path_var = path;
1991         int64_tArray path_arr = NULL;
1992         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1993         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1994         for (size_t k = 0; k < path_var.datalen; k++) {
1995                 LDKRouteHop path_conv_10_var = path_var.data[k];
1996                 int64_t path_conv_10_ref = 0;
1997                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1998                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1999                 path_arr_ptr[k] = path_conv_10_ref;
2000         }
2001         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2002         FREE(path_var.data);
2003         int64_t short_channel_id_conv = short_channel_id;
2004         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2005         CHECK(obj != NULL);
2006         (*env)->CallVoidMethod(env, obj, j_calls->probe_failed_meth, path_arr, short_channel_id_conv);
2007         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2008                 (*env)->ExceptionDescribe(env);
2009                 (*env)->FatalError(env, "A call to probe_failed in LDKScore from rust threw an exception.");
2010         }
2011         if (get_jenv_res == JNI_EDETACHED) {
2012                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2013         }
2014 }
2015 void probe_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
2016         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
2017         JNIEnv *env;
2018         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2019         if (get_jenv_res == JNI_EDETACHED) {
2020                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2021         } else {
2022                 DO_ASSERT(get_jenv_res == JNI_OK);
2023         }
2024         LDKCVec_RouteHopZ path_var = path;
2025         int64_tArray path_arr = NULL;
2026         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2027         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2028         for (size_t k = 0; k < path_var.datalen; k++) {
2029                 LDKRouteHop path_conv_10_var = path_var.data[k];
2030                 int64_t path_conv_10_ref = 0;
2031                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2032                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
2033                 path_arr_ptr[k] = path_conv_10_ref;
2034         }
2035         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2036         FREE(path_var.data);
2037         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2038         CHECK(obj != NULL);
2039         (*env)->CallVoidMethod(env, obj, j_calls->probe_successful_meth, path_arr);
2040         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2041                 (*env)->ExceptionDescribe(env);
2042                 (*env)->FatalError(env, "A call to probe_successful in LDKScore from rust threw an exception.");
2043         }
2044         if (get_jenv_res == JNI_EDETACHED) {
2045                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2046         }
2047 }
2048 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
2049         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
2050         JNIEnv *env;
2051         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2052         if (get_jenv_res == JNI_EDETACHED) {
2053                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2054         } else {
2055                 DO_ASSERT(get_jenv_res == JNI_OK);
2056         }
2057         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2058         CHECK(obj != NULL);
2059         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2060         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2061                 (*env)->ExceptionDescribe(env);
2062                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
2063         }
2064         LDKCVec_u8Z ret_ref;
2065         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2066         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2067         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2068         if (get_jenv_res == JNI_EDETACHED) {
2069                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2070         }
2071         return ret_ref;
2072 }
2073 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
2074         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
2075         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2076 }
2077 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
2078         jclass c = (*env)->GetObjectClass(env, o);
2079         CHECK(c != NULL);
2080         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
2081         atomic_init(&calls->refcnt, 1);
2082         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2083         calls->o = (*env)->NewWeakGlobalRef(env, o);
2084         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJ)J");
2085         CHECK(calls->channel_penalty_msat_meth != NULL);
2086         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
2087         CHECK(calls->payment_path_failed_meth != NULL);
2088         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
2089         CHECK(calls->payment_path_successful_meth != NULL);
2090         calls->probe_failed_meth = (*env)->GetMethodID(env, c, "probe_failed", "([JJ)V");
2091         CHECK(calls->probe_failed_meth != NULL);
2092         calls->probe_successful_meth = (*env)->GetMethodID(env, c, "probe_successful", "([J)V");
2093         CHECK(calls->probe_successful_meth != NULL);
2094         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2095         CHECK(calls->write_meth != NULL);
2096
2097         LDKScore ret = {
2098                 .this_arg = (void*) calls,
2099                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
2100                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
2101                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
2102                 .probe_failed = probe_failed_LDKScore_jcall,
2103                 .probe_successful = probe_successful_LDKScore_jcall,
2104                 .write = write_LDKScore_jcall,
2105                 .free = LDKScore_JCalls_free,
2106         };
2107         return ret;
2108 }
2109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
2110         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
2111         *res_ptr = LDKScore_init(env, clz, o);
2112         return tag_ptr(res_ptr, true);
2113 }
2114 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) {
2115         void* this_arg_ptr = untag_ptr(this_arg);
2116         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2117         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2118         LDKNodeId source_conv;
2119         source_conv.inner = untag_ptr(source);
2120         source_conv.is_owned = ptr_is_owned(source);
2121         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
2122         source_conv.is_owned = false;
2123         LDKNodeId target_conv;
2124         target_conv.inner = untag_ptr(target);
2125         target_conv.is_owned = ptr_is_owned(target);
2126         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
2127         target_conv.is_owned = false;
2128         LDKChannelUsage usage_conv;
2129         usage_conv.inner = untag_ptr(usage);
2130         usage_conv.is_owned = ptr_is_owned(usage);
2131         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
2132         usage_conv = ChannelUsage_clone(&usage_conv);
2133         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
2134         return ret_conv;
2135 }
2136
2137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
2138         void* this_arg_ptr = untag_ptr(this_arg);
2139         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2140         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2141         LDKCVec_RouteHopZ path_constr;
2142         path_constr.datalen = (*env)->GetArrayLength(env, path);
2143         if (path_constr.datalen > 0)
2144                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
2145         else
2146                 path_constr.data = NULL;
2147         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
2148         for (size_t k = 0; k < path_constr.datalen; k++) {
2149                 int64_t path_conv_10 = path_vals[k];
2150                 LDKRouteHop path_conv_10_conv;
2151                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
2152                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
2153                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
2154                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2155                 path_constr.data[k] = path_conv_10_conv;
2156         }
2157         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2158         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
2159 }
2160
2161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
2162         void* this_arg_ptr = untag_ptr(this_arg);
2163         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2164         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2165         LDKCVec_RouteHopZ path_constr;
2166         path_constr.datalen = (*env)->GetArrayLength(env, path);
2167         if (path_constr.datalen > 0)
2168                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
2169         else
2170                 path_constr.data = NULL;
2171         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
2172         for (size_t k = 0; k < path_constr.datalen; k++) {
2173                 int64_t path_conv_10 = path_vals[k];
2174                 LDKRouteHop path_conv_10_conv;
2175                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
2176                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
2177                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
2178                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2179                 path_constr.data[k] = path_conv_10_conv;
2180         }
2181         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2182         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
2183 }
2184
2185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
2186         void* this_arg_ptr = untag_ptr(this_arg);
2187         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2188         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2189         LDKCVec_RouteHopZ path_constr;
2190         path_constr.datalen = (*env)->GetArrayLength(env, path);
2191         if (path_constr.datalen > 0)
2192                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
2193         else
2194                 path_constr.data = NULL;
2195         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
2196         for (size_t k = 0; k < path_constr.datalen; k++) {
2197                 int64_t path_conv_10 = path_vals[k];
2198                 LDKRouteHop path_conv_10_conv;
2199                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
2200                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
2201                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
2202                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2203                 path_constr.data[k] = path_conv_10_conv;
2204         }
2205         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2206         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
2207 }
2208
2209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
2210         void* this_arg_ptr = untag_ptr(this_arg);
2211         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2212         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2213         LDKCVec_RouteHopZ path_constr;
2214         path_constr.datalen = (*env)->GetArrayLength(env, path);
2215         if (path_constr.datalen > 0)
2216                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
2217         else
2218                 path_constr.data = NULL;
2219         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
2220         for (size_t k = 0; k < path_constr.datalen; k++) {
2221                 int64_t path_conv_10 = path_vals[k];
2222                 LDKRouteHop path_conv_10_conv;
2223                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
2224                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
2225                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
2226                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2227                 path_constr.data[k] = path_conv_10_conv;
2228         }
2229         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2230         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, path_constr);
2231 }
2232
2233 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2234         void* this_arg_ptr = untag_ptr(this_arg);
2235         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2236         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2237         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2238         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2239         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2240         CVec_u8Z_free(ret_var);
2241         return ret_arr;
2242 }
2243
2244 typedef struct LDKLockableScore_JCalls {
2245         atomic_size_t refcnt;
2246         JavaVM *vm;
2247         jweak o;
2248         jmethodID lock_meth;
2249 } LDKLockableScore_JCalls;
2250 static void LDKLockableScore_JCalls_free(void* this_arg) {
2251         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2252         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2253                 JNIEnv *env;
2254                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2255                 if (get_jenv_res == JNI_EDETACHED) {
2256                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2257                 } else {
2258                         DO_ASSERT(get_jenv_res == JNI_OK);
2259                 }
2260                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2261                 if (get_jenv_res == JNI_EDETACHED) {
2262                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2263                 }
2264                 FREE(j_calls);
2265         }
2266 }
2267 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
2268         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2269         JNIEnv *env;
2270         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2271         if (get_jenv_res == JNI_EDETACHED) {
2272                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2273         } else {
2274                 DO_ASSERT(get_jenv_res == JNI_OK);
2275         }
2276         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2277         CHECK(obj != NULL);
2278         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
2279         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2280                 (*env)->ExceptionDescribe(env);
2281                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
2282         }
2283         void* ret_ptr = untag_ptr(ret);
2284         CHECK_ACCESS(ret_ptr);
2285         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
2286         if (ret_conv.free == LDKScore_JCalls_free) {
2287                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2288                 LDKScore_JCalls_cloned(&ret_conv);
2289         }// WARNING: we may need a move here but no clone is available for LDKScore
2290         
2291         if (get_jenv_res == JNI_EDETACHED) {
2292                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2293         }
2294         return ret_conv;
2295 }
2296 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
2297         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
2298         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2299 }
2300 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
2301         jclass c = (*env)->GetObjectClass(env, o);
2302         CHECK(c != NULL);
2303         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
2304         atomic_init(&calls->refcnt, 1);
2305         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2306         calls->o = (*env)->NewWeakGlobalRef(env, o);
2307         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
2308         CHECK(calls->lock_meth != NULL);
2309
2310         LDKLockableScore ret = {
2311                 .this_arg = (void*) calls,
2312                 .lock = lock_LDKLockableScore_jcall,
2313                 .free = LDKLockableScore_JCalls_free,
2314         };
2315         return ret;
2316 }
2317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
2318         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
2319         *res_ptr = LDKLockableScore_init(env, clz, o);
2320         return tag_ptr(res_ptr, true);
2321 }
2322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
2323         void* this_arg_ptr = untag_ptr(this_arg);
2324         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2325         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
2326         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
2327         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
2328         return tag_ptr(ret_ret, true);
2329 }
2330
2331 typedef struct LDKWriteableScore_JCalls {
2332         atomic_size_t refcnt;
2333         JavaVM *vm;
2334         jweak o;
2335         LDKLockableScore_JCalls* LockableScore;
2336         jmethodID write_meth;
2337 } LDKWriteableScore_JCalls;
2338 static void LDKWriteableScore_JCalls_free(void* this_arg) {
2339         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2340         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2341                 JNIEnv *env;
2342                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2343                 if (get_jenv_res == JNI_EDETACHED) {
2344                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2345                 } else {
2346                         DO_ASSERT(get_jenv_res == JNI_OK);
2347                 }
2348                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2349                 if (get_jenv_res == JNI_EDETACHED) {
2350                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2351                 }
2352                 FREE(j_calls);
2353         }
2354 }
2355 LDKCVec_u8Z write_LDKWriteableScore_jcall(const void* this_arg) {
2356         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2357         JNIEnv *env;
2358         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2359         if (get_jenv_res == JNI_EDETACHED) {
2360                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2361         } else {
2362                 DO_ASSERT(get_jenv_res == JNI_OK);
2363         }
2364         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2365         CHECK(obj != NULL);
2366         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2367         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2368                 (*env)->ExceptionDescribe(env);
2369                 (*env)->FatalError(env, "A call to write in LDKWriteableScore from rust threw an exception.");
2370         }
2371         LDKCVec_u8Z ret_ref;
2372         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2373         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2374         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2375         if (get_jenv_res == JNI_EDETACHED) {
2376                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2377         }
2378         return ret_ref;
2379 }
2380 static void LDKWriteableScore_JCalls_cloned(LDKWriteableScore* new_obj) {
2381         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) new_obj->this_arg;
2382         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2383         atomic_fetch_add_explicit(&j_calls->LockableScore->refcnt, 1, memory_order_release);
2384 }
2385 static inline LDKWriteableScore LDKWriteableScore_init (JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2386         jclass c = (*env)->GetObjectClass(env, o);
2387         CHECK(c != NULL);
2388         LDKWriteableScore_JCalls *calls = MALLOC(sizeof(LDKWriteableScore_JCalls), "LDKWriteableScore_JCalls");
2389         atomic_init(&calls->refcnt, 1);
2390         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2391         calls->o = (*env)->NewWeakGlobalRef(env, o);
2392         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2393         CHECK(calls->write_meth != NULL);
2394
2395         LDKWriteableScore ret = {
2396                 .this_arg = (void*) calls,
2397                 .write = write_LDKWriteableScore_jcall,
2398                 .free = LDKWriteableScore_JCalls_free,
2399                 .LockableScore = LDKLockableScore_init(env, clz, LockableScore),
2400         };
2401         calls->LockableScore = ret.LockableScore.this_arg;
2402         return ret;
2403 }
2404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1new(JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2405         LDKWriteableScore *res_ptr = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2406         *res_ptr = LDKWriteableScore_init(env, clz, o, LockableScore);
2407         return tag_ptr(res_ptr, true);
2408 }
2409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1get_1LockableScore(JNIEnv *env, jclass clz, int64_t arg) {
2410         LDKWriteableScore *inp = (LDKWriteableScore *)untag_ptr(arg);
2411         return tag_ptr(&inp->LockableScore, false);
2412 }
2413 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WriteableScore_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2414         void* this_arg_ptr = untag_ptr(this_arg);
2415         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2416         LDKWriteableScore* this_arg_conv = (LDKWriteableScore*)this_arg_ptr;
2417         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2418         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2419         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2420         CVec_u8Z_free(ret_var);
2421         return ret_arr;
2422 }
2423
2424 static jclass LDKCOption_WriteableScoreZ_Some_class = NULL;
2425 static jmethodID LDKCOption_WriteableScoreZ_Some_meth = NULL;
2426 static jclass LDKCOption_WriteableScoreZ_None_class = NULL;
2427 static jmethodID LDKCOption_WriteableScoreZ_None_meth = NULL;
2428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1WriteableScoreZ_init (JNIEnv *env, jclass clz) {
2429         LDKCOption_WriteableScoreZ_Some_class =
2430                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$Some"));
2431         CHECK(LDKCOption_WriteableScoreZ_Some_class != NULL);
2432         LDKCOption_WriteableScoreZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_Some_class, "<init>", "(J)V");
2433         CHECK(LDKCOption_WriteableScoreZ_Some_meth != NULL);
2434         LDKCOption_WriteableScoreZ_None_class =
2435                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$None"));
2436         CHECK(LDKCOption_WriteableScoreZ_None_class != NULL);
2437         LDKCOption_WriteableScoreZ_None_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_None_class, "<init>", "()V");
2438         CHECK(LDKCOption_WriteableScoreZ_None_meth != NULL);
2439 }
2440 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1WriteableScoreZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2441         LDKCOption_WriteableScoreZ *obj = (LDKCOption_WriteableScoreZ*)untag_ptr(ptr);
2442         switch(obj->tag) {
2443                 case LDKCOption_WriteableScoreZ_Some: {
2444                         LDKWriteableScore* some_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2445                         *some_ret = obj->some;
2446                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
2447                         if ((*some_ret).free == LDKWriteableScore_JCalls_free) {
2448                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2449                                 LDKWriteableScore_JCalls_cloned(&(*some_ret));
2450                         }
2451                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_Some_class, LDKCOption_WriteableScoreZ_Some_meth, tag_ptr(some_ret, true));
2452                 }
2453                 case LDKCOption_WriteableScoreZ_None: {
2454                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_None_class, LDKCOption_WriteableScoreZ_None_meth);
2455                 }
2456                 default: abort();
2457         }
2458 }
2459 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2460 CHECK(owner->result_ok);
2461         return *owner->contents.result;
2462 }
2463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2464         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2465         CResult_NoneErrorZ_get_ok(owner_conv);
2466 }
2467
2468 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2469 CHECK(!owner->result_ok);
2470         return *owner->contents.err;
2471 }
2472 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2473         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2474         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
2475         return ret_conv;
2476 }
2477
2478 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2479         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2480         for (size_t i = 0; i < ret.datalen; i++) {
2481                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2482         }
2483         return ret;
2484 }
2485 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2486         LDKRoute ret = *owner->contents.result;
2487         ret.is_owned = false;
2488         return ret;
2489 }
2490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2491         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2492         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
2493         int64_t ret_ref = 0;
2494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2495         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2496         return ret_ref;
2497 }
2498
2499 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2500         LDKLightningError ret = *owner->contents.err;
2501         ret.is_owned = false;
2502         return ret;
2503 }
2504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2505         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2506         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
2507         int64_t ret_ref = 0;
2508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2509         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2510         return ret_ref;
2511 }
2512
2513 static jclass LDKCOption_u64Z_Some_class = NULL;
2514 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
2515 static jclass LDKCOption_u64Z_None_class = NULL;
2516 static jmethodID LDKCOption_u64Z_None_meth = NULL;
2517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
2518         LDKCOption_u64Z_Some_class =
2519                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
2520         CHECK(LDKCOption_u64Z_Some_class != NULL);
2521         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
2522         CHECK(LDKCOption_u64Z_Some_meth != NULL);
2523         LDKCOption_u64Z_None_class =
2524                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
2525         CHECK(LDKCOption_u64Z_None_class != NULL);
2526         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
2527         CHECK(LDKCOption_u64Z_None_meth != NULL);
2528 }
2529 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2530         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)untag_ptr(ptr);
2531         switch(obj->tag) {
2532                 case LDKCOption_u64Z_Some: {
2533                         int64_t some_conv = obj->some;
2534                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
2535                 }
2536                 case LDKCOption_u64Z_None: {
2537                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
2538                 }
2539                 default: abort();
2540         }
2541 }
2542 static inline struct LDKInFlightHtlcs CResult_InFlightHtlcsDecodeErrorZ_get_ok(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
2543         LDKInFlightHtlcs ret = *owner->contents.result;
2544         ret.is_owned = false;
2545         return ret;
2546 }
2547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2548         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
2549         LDKInFlightHtlcs ret_var = CResult_InFlightHtlcsDecodeErrorZ_get_ok(owner_conv);
2550         int64_t ret_ref = 0;
2551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2552         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2553         return ret_ref;
2554 }
2555
2556 static inline struct LDKDecodeError CResult_InFlightHtlcsDecodeErrorZ_get_err(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
2557 CHECK(!owner->result_ok);
2558         return DecodeError_clone(&*owner->contents.err);
2559 }
2560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2561         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
2562         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2563         *ret_copy = CResult_InFlightHtlcsDecodeErrorZ_get_err(owner_conv);
2564         int64_t ret_ref = tag_ptr(ret_copy, true);
2565         return ret_ref;
2566 }
2567
2568 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2569         LDKRouteHop ret = *owner->contents.result;
2570         ret.is_owned = false;
2571         return ret;
2572 }
2573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2574         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2575         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
2576         int64_t ret_ref = 0;
2577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2578         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2579         return ret_ref;
2580 }
2581
2582 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2583 CHECK(!owner->result_ok);
2584         return DecodeError_clone(&*owner->contents.err);
2585 }
2586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2587         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2588         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2589         *ret_copy = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
2590         int64_t ret_ref = tag_ptr(ret_copy, true);
2591         return ret_ref;
2592 }
2593
2594 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2595         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2596         for (size_t i = 0; i < ret.datalen; i++) {
2597                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2598         }
2599         return ret;
2600 }
2601 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2602         LDKRoute ret = *owner->contents.result;
2603         ret.is_owned = false;
2604         return ret;
2605 }
2606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2607         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2608         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
2609         int64_t ret_ref = 0;
2610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2611         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2612         return ret_ref;
2613 }
2614
2615 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2616 CHECK(!owner->result_ok);
2617         return DecodeError_clone(&*owner->contents.err);
2618 }
2619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2620         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2621         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2622         *ret_copy = CResult_RouteDecodeErrorZ_get_err(owner_conv);
2623         int64_t ret_ref = tag_ptr(ret_copy, true);
2624         return ret_ref;
2625 }
2626
2627 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2628         LDKRouteParameters ret = *owner->contents.result;
2629         ret.is_owned = false;
2630         return ret;
2631 }
2632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2633         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2634         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
2635         int64_t ret_ref = 0;
2636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2637         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2638         return ret_ref;
2639 }
2640
2641 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2642 CHECK(!owner->result_ok);
2643         return DecodeError_clone(&*owner->contents.err);
2644 }
2645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2646         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2647         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2648         *ret_copy = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
2649         int64_t ret_ref = tag_ptr(ret_copy, true);
2650         return ret_ref;
2651 }
2652
2653 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2654         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2655         for (size_t i = 0; i < ret.datalen; i++) {
2656                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2657         }
2658         return ret;
2659 }
2660 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
2661         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
2662         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
2663         return ret;
2664 }
2665 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2666         LDKPaymentParameters ret = *owner->contents.result;
2667         ret.is_owned = false;
2668         return ret;
2669 }
2670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2671         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2672         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
2673         int64_t ret_ref = 0;
2674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2675         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2676         return ret_ref;
2677 }
2678
2679 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2680 CHECK(!owner->result_ok);
2681         return DecodeError_clone(&*owner->contents.err);
2682 }
2683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2684         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2685         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2686         *ret_copy = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
2687         int64_t ret_ref = tag_ptr(ret_copy, true);
2688         return ret_ref;
2689 }
2690
2691 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
2692         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
2693         for (size_t i = 0; i < ret.datalen; i++) {
2694                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
2695         }
2696         return ret;
2697 }
2698 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2699         LDKRouteHint ret = *owner->contents.result;
2700         ret.is_owned = false;
2701         return ret;
2702 }
2703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2704         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2705         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
2706         int64_t ret_ref = 0;
2707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2708         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2709         return ret_ref;
2710 }
2711
2712 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2713 CHECK(!owner->result_ok);
2714         return DecodeError_clone(&*owner->contents.err);
2715 }
2716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2717         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2718         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2719         *ret_copy = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
2720         int64_t ret_ref = tag_ptr(ret_copy, true);
2721         return ret_ref;
2722 }
2723
2724 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2725         LDKRouteHintHop ret = *owner->contents.result;
2726         ret.is_owned = false;
2727         return ret;
2728 }
2729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2730         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2731         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
2732         int64_t ret_ref = 0;
2733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2734         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2735         return ret_ref;
2736 }
2737
2738 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2739 CHECK(!owner->result_ok);
2740         return DecodeError_clone(&*owner->contents.err);
2741 }
2742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2743         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2744         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2745         *ret_copy = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
2746         int64_t ret_ref = tag_ptr(ret_copy, true);
2747         return ret_ref;
2748 }
2749
2750 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
2751 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
2752 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
2753 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
2754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
2755         LDKPaymentPurpose_InvoicePayment_class =
2756                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
2757         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
2758         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
2759         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
2760         LDKPaymentPurpose_SpontaneousPayment_class =
2761                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
2762         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
2763         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
2764         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
2765 }
2766 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2767         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
2768         switch(obj->tag) {
2769                 case LDKPaymentPurpose_InvoicePayment: {
2770                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2771                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
2772                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
2773                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
2774                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
2775                 }
2776                 case LDKPaymentPurpose_SpontaneousPayment: {
2777                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
2778                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
2779                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
2780                 }
2781                 default: abort();
2782         }
2783 }
2784 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
2785 CHECK(owner->result_ok);
2786         return PaymentPurpose_clone(&*owner->contents.result);
2787 }
2788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2789         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
2790         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
2791         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
2792         int64_t ret_ref = tag_ptr(ret_copy, true);
2793         return ret_ref;
2794 }
2795
2796 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
2797 CHECK(!owner->result_ok);
2798         return DecodeError_clone(&*owner->contents.err);
2799 }
2800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2801         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
2802         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2803         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
2804         int64_t ret_ref = tag_ptr(ret_copy, true);
2805         return ret_ref;
2806 }
2807
2808 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2809 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2810 static jclass LDKNetworkUpdate_ChannelFailure_class = NULL;
2811 static jmethodID LDKNetworkUpdate_ChannelFailure_meth = NULL;
2812 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2813 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2815         LDKNetworkUpdate_ChannelUpdateMessage_class =
2816                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2817         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2818         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2819         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2820         LDKNetworkUpdate_ChannelFailure_class =
2821                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelFailure"));
2822         CHECK(LDKNetworkUpdate_ChannelFailure_class != NULL);
2823         LDKNetworkUpdate_ChannelFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelFailure_class, "<init>", "(JZ)V");
2824         CHECK(LDKNetworkUpdate_ChannelFailure_meth != NULL);
2825         LDKNetworkUpdate_NodeFailure_class =
2826                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2827         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2828         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2829         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2830 }
2831 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2832         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
2833         switch(obj->tag) {
2834                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2835                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2836                         int64_t msg_ref = 0;
2837                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2838                         msg_ref = tag_ptr(msg_var.inner, false);
2839                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2840                 }
2841                 case LDKNetworkUpdate_ChannelFailure: {
2842                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
2843                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
2844                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelFailure_class, LDKNetworkUpdate_ChannelFailure_meth, short_channel_id_conv, is_permanent_conv);
2845                 }
2846                 case LDKNetworkUpdate_NodeFailure: {
2847                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2848                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2849                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
2850                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
2851                 }
2852                 default: abort();
2853         }
2854 }
2855 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2856 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2857 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2858 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2860         LDKCOption_NetworkUpdateZ_Some_class =
2861                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2862         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2863         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2864         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2865         LDKCOption_NetworkUpdateZ_None_class =
2866                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2867         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2868         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2869         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2870 }
2871 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2872         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)untag_ptr(ptr);
2873         switch(obj->tag) {
2874                 case LDKCOption_NetworkUpdateZ_Some: {
2875                         int64_t some_ref = tag_ptr(&obj->some, false);
2876                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2877                 }
2878                 case LDKCOption_NetworkUpdateZ_None: {
2879                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2880                 }
2881                 default: abort();
2882         }
2883 }
2884 static jclass LDKPathFailure_InitialSend_class = NULL;
2885 static jmethodID LDKPathFailure_InitialSend_meth = NULL;
2886 static jclass LDKPathFailure_OnPath_class = NULL;
2887 static jmethodID LDKPathFailure_OnPath_meth = NULL;
2888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPathFailure_init (JNIEnv *env, jclass clz) {
2889         LDKPathFailure_InitialSend_class =
2890                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPathFailure$InitialSend"));
2891         CHECK(LDKPathFailure_InitialSend_class != NULL);
2892         LDKPathFailure_InitialSend_meth = (*env)->GetMethodID(env, LDKPathFailure_InitialSend_class, "<init>", "(J)V");
2893         CHECK(LDKPathFailure_InitialSend_meth != NULL);
2894         LDKPathFailure_OnPath_class =
2895                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPathFailure$OnPath"));
2896         CHECK(LDKPathFailure_OnPath_class != NULL);
2897         LDKPathFailure_OnPath_meth = (*env)->GetMethodID(env, LDKPathFailure_OnPath_class, "<init>", "(J)V");
2898         CHECK(LDKPathFailure_OnPath_meth != NULL);
2899 }
2900 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPathFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2901         LDKPathFailure *obj = (LDKPathFailure*)untag_ptr(ptr);
2902         switch(obj->tag) {
2903                 case LDKPathFailure_InitialSend: {
2904                         int64_t err_ref = tag_ptr(&obj->initial_send.err, false);
2905                         return (*env)->NewObject(env, LDKPathFailure_InitialSend_class, LDKPathFailure_InitialSend_meth, err_ref);
2906                 }
2907                 case LDKPathFailure_OnPath: {
2908                         int64_t network_update_ref = tag_ptr(&obj->on_path.network_update, false);
2909                         return (*env)->NewObject(env, LDKPathFailure_OnPath_class, LDKPathFailure_OnPath_meth, network_update_ref);
2910                 }
2911                 default: abort();
2912         }
2913 }
2914 static jclass LDKCOption_PathFailureZ_Some_class = NULL;
2915 static jmethodID LDKCOption_PathFailureZ_Some_meth = NULL;
2916 static jclass LDKCOption_PathFailureZ_None_class = NULL;
2917 static jmethodID LDKCOption_PathFailureZ_None_meth = NULL;
2918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1PathFailureZ_init (JNIEnv *env, jclass clz) {
2919         LDKCOption_PathFailureZ_Some_class =
2920                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_PathFailureZ$Some"));
2921         CHECK(LDKCOption_PathFailureZ_Some_class != NULL);
2922         LDKCOption_PathFailureZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_PathFailureZ_Some_class, "<init>", "(J)V");
2923         CHECK(LDKCOption_PathFailureZ_Some_meth != NULL);
2924         LDKCOption_PathFailureZ_None_class =
2925                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_PathFailureZ$None"));
2926         CHECK(LDKCOption_PathFailureZ_None_class != NULL);
2927         LDKCOption_PathFailureZ_None_meth = (*env)->GetMethodID(env, LDKCOption_PathFailureZ_None_class, "<init>", "()V");
2928         CHECK(LDKCOption_PathFailureZ_None_meth != NULL);
2929 }
2930 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1PathFailureZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2931         LDKCOption_PathFailureZ *obj = (LDKCOption_PathFailureZ*)untag_ptr(ptr);
2932         switch(obj->tag) {
2933                 case LDKCOption_PathFailureZ_Some: {
2934                         int64_t some_ref = tag_ptr(&obj->some, false);
2935                         return (*env)->NewObject(env, LDKCOption_PathFailureZ_Some_class, LDKCOption_PathFailureZ_Some_meth, some_ref);
2936                 }
2937                 case LDKCOption_PathFailureZ_None: {
2938                         return (*env)->NewObject(env, LDKCOption_PathFailureZ_None_class, LDKCOption_PathFailureZ_None_meth);
2939                 }
2940                 default: abort();
2941         }
2942 }
2943 static inline struct LDKCOption_PathFailureZ CResult_COption_PathFailureZDecodeErrorZ_get_ok(LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR owner){
2944 CHECK(owner->result_ok);
2945         return COption_PathFailureZ_clone(&*owner->contents.result);
2946 }
2947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2948         LDKCResult_COption_PathFailureZDecodeErrorZ* owner_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(owner);
2949         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
2950         *ret_copy = CResult_COption_PathFailureZDecodeErrorZ_get_ok(owner_conv);
2951         int64_t ret_ref = tag_ptr(ret_copy, true);
2952         return ret_ref;
2953 }
2954
2955 static inline struct LDKDecodeError CResult_COption_PathFailureZDecodeErrorZ_get_err(LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR owner){
2956 CHECK(!owner->result_ok);
2957         return DecodeError_clone(&*owner->contents.err);
2958 }
2959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2960         LDKCResult_COption_PathFailureZDecodeErrorZ* owner_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(owner);
2961         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2962         *ret_copy = CResult_COption_PathFailureZDecodeErrorZ_get_err(owner_conv);
2963         int64_t ret_ref = tag_ptr(ret_copy, true);
2964         return ret_ref;
2965 }
2966
2967 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
2968 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
2969 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
2970 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
2971 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
2972 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
2973 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
2974 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
2975 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
2976 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
2977 static jclass LDKClosureReason_ProcessingError_class = NULL;
2978 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
2979 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
2980 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
2981 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
2982 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
2983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
2984         LDKClosureReason_CounterpartyForceClosed_class =
2985                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
2986         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
2987         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
2988         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
2989         LDKClosureReason_HolderForceClosed_class =
2990                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
2991         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
2992         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2993         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2994         LDKClosureReason_CooperativeClosure_class =
2995                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2996         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2997         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2998         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2999         LDKClosureReason_CommitmentTxConfirmed_class =
3000                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
3001         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
3002         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
3003         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
3004         LDKClosureReason_FundingTimedOut_class =
3005                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
3006         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
3007         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
3008         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
3009         LDKClosureReason_ProcessingError_class =
3010                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
3011         CHECK(LDKClosureReason_ProcessingError_class != NULL);
3012         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
3013         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
3014         LDKClosureReason_DisconnectedPeer_class =
3015                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
3016         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
3017         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
3018         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
3019         LDKClosureReason_OutdatedChannelManager_class =
3020                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
3021         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
3022         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
3023         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
3024 }
3025 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3026         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
3027         switch(obj->tag) {
3028                 case LDKClosureReason_CounterpartyForceClosed: {
3029                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
3030                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
3031                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
3032                 }
3033                 case LDKClosureReason_HolderForceClosed: {
3034                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
3035                 }
3036                 case LDKClosureReason_CooperativeClosure: {
3037                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
3038                 }
3039                 case LDKClosureReason_CommitmentTxConfirmed: {
3040                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
3041                 }
3042                 case LDKClosureReason_FundingTimedOut: {
3043                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
3044                 }
3045                 case LDKClosureReason_ProcessingError: {
3046                         LDKStr err_str = obj->processing_error.err;
3047                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3048                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
3049                 }
3050                 case LDKClosureReason_DisconnectedPeer: {
3051                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
3052                 }
3053                 case LDKClosureReason_OutdatedChannelManager: {
3054                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
3055                 }
3056                 default: abort();
3057         }
3058 }
3059 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
3060 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
3061 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
3062 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
3063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
3064         LDKCOption_ClosureReasonZ_Some_class =
3065                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
3066         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
3067         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
3068         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
3069         LDKCOption_ClosureReasonZ_None_class =
3070                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
3071         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
3072         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
3073         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
3074 }
3075 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3076         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)untag_ptr(ptr);
3077         switch(obj->tag) {
3078                 case LDKCOption_ClosureReasonZ_Some: {
3079                         int64_t some_ref = tag_ptr(&obj->some, false);
3080                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
3081                 }
3082                 case LDKCOption_ClosureReasonZ_None: {
3083                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
3084                 }
3085                 default: abort();
3086         }
3087 }
3088 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
3089 CHECK(owner->result_ok);
3090         return COption_ClosureReasonZ_clone(&*owner->contents.result);
3091 }
3092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3093         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
3094         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
3095         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
3096         int64_t ret_ref = tag_ptr(ret_copy, true);
3097         return ret_ref;
3098 }
3099
3100 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
3101 CHECK(!owner->result_ok);
3102         return DecodeError_clone(&*owner->contents.err);
3103 }
3104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3105         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
3106         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3107         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
3108         int64_t ret_ref = tag_ptr(ret_copy, true);
3109         return ret_ref;
3110 }
3111
3112 static jclass LDKHTLCDestination_NextHopChannel_class = NULL;
3113 static jmethodID LDKHTLCDestination_NextHopChannel_meth = NULL;
3114 static jclass LDKHTLCDestination_UnknownNextHop_class = NULL;
3115 static jmethodID LDKHTLCDestination_UnknownNextHop_meth = NULL;
3116 static jclass LDKHTLCDestination_InvalidForward_class = NULL;
3117 static jmethodID LDKHTLCDestination_InvalidForward_meth = NULL;
3118 static jclass LDKHTLCDestination_FailedPayment_class = NULL;
3119 static jmethodID LDKHTLCDestination_FailedPayment_meth = NULL;
3120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCDestination_init (JNIEnv *env, jclass clz) {
3121         LDKHTLCDestination_NextHopChannel_class =
3122                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$NextHopChannel"));
3123         CHECK(LDKHTLCDestination_NextHopChannel_class != NULL);
3124         LDKHTLCDestination_NextHopChannel_meth = (*env)->GetMethodID(env, LDKHTLCDestination_NextHopChannel_class, "<init>", "([B[B)V");
3125         CHECK(LDKHTLCDestination_NextHopChannel_meth != NULL);
3126         LDKHTLCDestination_UnknownNextHop_class =
3127                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$UnknownNextHop"));
3128         CHECK(LDKHTLCDestination_UnknownNextHop_class != NULL);
3129         LDKHTLCDestination_UnknownNextHop_meth = (*env)->GetMethodID(env, LDKHTLCDestination_UnknownNextHop_class, "<init>", "(J)V");
3130         CHECK(LDKHTLCDestination_UnknownNextHop_meth != NULL);
3131         LDKHTLCDestination_InvalidForward_class =
3132                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$InvalidForward"));
3133         CHECK(LDKHTLCDestination_InvalidForward_class != NULL);
3134         LDKHTLCDestination_InvalidForward_meth = (*env)->GetMethodID(env, LDKHTLCDestination_InvalidForward_class, "<init>", "(J)V");
3135         CHECK(LDKHTLCDestination_InvalidForward_meth != NULL);
3136         LDKHTLCDestination_FailedPayment_class =
3137                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$FailedPayment"));
3138         CHECK(LDKHTLCDestination_FailedPayment_class != NULL);
3139         LDKHTLCDestination_FailedPayment_meth = (*env)->GetMethodID(env, LDKHTLCDestination_FailedPayment_class, "<init>", "([B)V");
3140         CHECK(LDKHTLCDestination_FailedPayment_meth != NULL);
3141 }
3142 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3143         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
3144         switch(obj->tag) {
3145                 case LDKHTLCDestination_NextHopChannel: {
3146                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3147                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->next_hop_channel.node_id.compressed_form);
3148                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3149                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->next_hop_channel.channel_id.data);
3150                         return (*env)->NewObject(env, LDKHTLCDestination_NextHopChannel_class, LDKHTLCDestination_NextHopChannel_meth, node_id_arr, channel_id_arr);
3151                 }
3152                 case LDKHTLCDestination_UnknownNextHop: {
3153                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
3154                         return (*env)->NewObject(env, LDKHTLCDestination_UnknownNextHop_class, LDKHTLCDestination_UnknownNextHop_meth, requested_forward_scid_conv);
3155                 }
3156                 case LDKHTLCDestination_InvalidForward: {
3157                         int64_t requested_forward_scid_conv = obj->invalid_forward.requested_forward_scid;
3158                         return (*env)->NewObject(env, LDKHTLCDestination_InvalidForward_class, LDKHTLCDestination_InvalidForward_meth, requested_forward_scid_conv);
3159                 }
3160                 case LDKHTLCDestination_FailedPayment: {
3161                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3162                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->failed_payment.payment_hash.data);
3163                         return (*env)->NewObject(env, LDKHTLCDestination_FailedPayment_class, LDKHTLCDestination_FailedPayment_meth, payment_hash_arr);
3164                 }
3165                 default: abort();
3166         }
3167 }
3168 static jclass LDKCOption_HTLCDestinationZ_Some_class = NULL;
3169 static jmethodID LDKCOption_HTLCDestinationZ_Some_meth = NULL;
3170 static jclass LDKCOption_HTLCDestinationZ_None_class = NULL;
3171 static jmethodID LDKCOption_HTLCDestinationZ_None_meth = NULL;
3172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCDestinationZ_init (JNIEnv *env, jclass clz) {
3173         LDKCOption_HTLCDestinationZ_Some_class =
3174                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$Some"));
3175         CHECK(LDKCOption_HTLCDestinationZ_Some_class != NULL);
3176         LDKCOption_HTLCDestinationZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_Some_class, "<init>", "(J)V");
3177         CHECK(LDKCOption_HTLCDestinationZ_Some_meth != NULL);
3178         LDKCOption_HTLCDestinationZ_None_class =
3179                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$None"));
3180         CHECK(LDKCOption_HTLCDestinationZ_None_class != NULL);
3181         LDKCOption_HTLCDestinationZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_None_class, "<init>", "()V");
3182         CHECK(LDKCOption_HTLCDestinationZ_None_meth != NULL);
3183 }
3184 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCDestinationZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3185         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)untag_ptr(ptr);
3186         switch(obj->tag) {
3187                 case LDKCOption_HTLCDestinationZ_Some: {
3188                         int64_t some_ref = tag_ptr(&obj->some, false);
3189                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_Some_class, LDKCOption_HTLCDestinationZ_Some_meth, some_ref);
3190                 }
3191                 case LDKCOption_HTLCDestinationZ_None: {
3192                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_None_class, LDKCOption_HTLCDestinationZ_None_meth);
3193                 }
3194                 default: abort();
3195         }
3196 }
3197 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
3198 CHECK(owner->result_ok);
3199         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
3200 }
3201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3202         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
3203         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
3204         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
3205         int64_t ret_ref = tag_ptr(ret_copy, true);
3206         return ret_ref;
3207 }
3208
3209 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
3210 CHECK(!owner->result_ok);
3211         return DecodeError_clone(&*owner->contents.err);
3212 }
3213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3214         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
3215         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3216         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
3217         int64_t ret_ref = tag_ptr(ret_copy, true);
3218         return ret_ref;
3219 }
3220
3221 static jclass LDKCOption_u128Z_Some_class = NULL;
3222 static jmethodID LDKCOption_u128Z_Some_meth = NULL;
3223 static jclass LDKCOption_u128Z_None_class = NULL;
3224 static jmethodID LDKCOption_u128Z_None_meth = NULL;
3225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u128Z_init (JNIEnv *env, jclass clz) {
3226         LDKCOption_u128Z_Some_class =
3227                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u128Z$Some"));
3228         CHECK(LDKCOption_u128Z_Some_class != NULL);
3229         LDKCOption_u128Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u128Z_Some_class, "<init>", "([B)V");
3230         CHECK(LDKCOption_u128Z_Some_meth != NULL);
3231         LDKCOption_u128Z_None_class =
3232                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u128Z$None"));
3233         CHECK(LDKCOption_u128Z_None_class != NULL);
3234         LDKCOption_u128Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u128Z_None_class, "<init>", "()V");
3235         CHECK(LDKCOption_u128Z_None_meth != NULL);
3236 }
3237 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u128Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3238         LDKCOption_u128Z *obj = (LDKCOption_u128Z*)untag_ptr(ptr);
3239         switch(obj->tag) {
3240                 case LDKCOption_u128Z_Some: {
3241                         int8_tArray some_arr = (*env)->NewByteArray(env, 16);
3242                         (*env)->SetByteArrayRegion(env, some_arr, 0, 16, obj->some.le_bytes);
3243                         return (*env)->NewObject(env, LDKCOption_u128Z_Some_class, LDKCOption_u128Z_Some_meth, some_arr);
3244                 }
3245                 case LDKCOption_u128Z_None: {
3246                         return (*env)->NewObject(env, LDKCOption_u128Z_None_class, LDKCOption_u128Z_None_meth);
3247                 }
3248                 default: abort();
3249         }
3250 }
3251 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
3252 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
3253 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
3254 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
3255 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
3256 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
3257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
3258         LDKSpendableOutputDescriptor_StaticOutput_class =
3259                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
3260         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
3261         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
3262         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
3263         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
3264                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
3265         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
3266         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
3267         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
3268         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
3269                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
3270         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
3271         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
3272         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
3273 }
3274 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3275         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
3276         switch(obj->tag) {
3277                 case LDKSpendableOutputDescriptor_StaticOutput: {
3278                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
3279                         int64_t outpoint_ref = 0;
3280                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
3281                         outpoint_ref = tag_ptr(outpoint_var.inner, false);
3282                         LDKTxOut* output_ref = &obj->static_output.output;
3283                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, tag_ptr(output_ref, false));
3284                 }
3285                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
3286                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
3287                         int64_t delayed_payment_output_ref = 0;
3288                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
3289                         delayed_payment_output_ref = tag_ptr(delayed_payment_output_var.inner, false);
3290                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
3291                 }
3292                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
3293                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
3294                         int64_t static_payment_output_ref = 0;
3295                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
3296                         static_payment_output_ref = tag_ptr(static_payment_output_var.inner, false);
3297                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
3298                 }
3299                 default: abort();
3300         }
3301 }
3302 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
3303         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
3304         for (size_t i = 0; i < ret.datalen; i++) {
3305                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
3306         }
3307         return ret;
3308 }
3309 static jclass LDKEvent_FundingGenerationReady_class = NULL;
3310 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
3311 static jclass LDKEvent_PaymentClaimable_class = NULL;
3312 static jmethodID LDKEvent_PaymentClaimable_meth = NULL;
3313 static jclass LDKEvent_PaymentClaimed_class = NULL;
3314 static jmethodID LDKEvent_PaymentClaimed_meth = NULL;
3315 static jclass LDKEvent_PaymentSent_class = NULL;
3316 static jmethodID LDKEvent_PaymentSent_meth = NULL;
3317 static jclass LDKEvent_PaymentFailed_class = NULL;
3318 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
3319 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
3320 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
3321 static jclass LDKEvent_PaymentPathFailed_class = NULL;
3322 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
3323 static jclass LDKEvent_ProbeSuccessful_class = NULL;
3324 static jmethodID LDKEvent_ProbeSuccessful_meth = NULL;
3325 static jclass LDKEvent_ProbeFailed_class = NULL;
3326 static jmethodID LDKEvent_ProbeFailed_meth = NULL;
3327 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
3328 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
3329 static jclass LDKEvent_HTLCIntercepted_class = NULL;
3330 static jmethodID LDKEvent_HTLCIntercepted_meth = NULL;
3331 static jclass LDKEvent_SpendableOutputs_class = NULL;
3332 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
3333 static jclass LDKEvent_PaymentForwarded_class = NULL;
3334 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
3335 static jclass LDKEvent_ChannelReady_class = NULL;
3336 static jmethodID LDKEvent_ChannelReady_meth = NULL;
3337 static jclass LDKEvent_ChannelClosed_class = NULL;
3338 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
3339 static jclass LDKEvent_DiscardFunding_class = NULL;
3340 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
3341 static jclass LDKEvent_OpenChannelRequest_class = NULL;
3342 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
3343 static jclass LDKEvent_HTLCHandlingFailed_class = NULL;
3344 static jmethodID LDKEvent_HTLCHandlingFailed_meth = NULL;
3345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
3346         LDKEvent_FundingGenerationReady_class =
3347                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
3348         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
3349         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([B[BJ[B[B)V");
3350         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
3351         LDKEvent_PaymentClaimable_class =
3352                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimable"));
3353         CHECK(LDKEvent_PaymentClaimable_class != NULL);
3354         LDKEvent_PaymentClaimable_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimable_class, "<init>", "([B[BJJ[BJ)V");
3355         CHECK(LDKEvent_PaymentClaimable_meth != NULL);
3356         LDKEvent_PaymentClaimed_class =
3357                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimed"));
3358         CHECK(LDKEvent_PaymentClaimed_class != NULL);
3359         LDKEvent_PaymentClaimed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimed_class, "<init>", "([B[BJJ)V");
3360         CHECK(LDKEvent_PaymentClaimed_meth != NULL);
3361         LDKEvent_PaymentSent_class =
3362                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
3363         CHECK(LDKEvent_PaymentSent_class != NULL);
3364         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
3365         CHECK(LDKEvent_PaymentSent_meth != NULL);
3366         LDKEvent_PaymentFailed_class =
3367                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
3368         CHECK(LDKEvent_PaymentFailed_class != NULL);
3369         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
3370         CHECK(LDKEvent_PaymentFailed_meth != NULL);
3371         LDKEvent_PaymentPathSuccessful_class =
3372                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
3373         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
3374         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
3375         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
3376         LDKEvent_PaymentPathFailed_class =
3377                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
3378         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
3379         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJ[JJJ)V");
3380         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
3381         LDKEvent_ProbeSuccessful_class =
3382                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeSuccessful"));
3383         CHECK(LDKEvent_ProbeSuccessful_class != NULL);
3384         LDKEvent_ProbeSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_ProbeSuccessful_class, "<init>", "([B[B[J)V");
3385         CHECK(LDKEvent_ProbeSuccessful_meth != NULL);
3386         LDKEvent_ProbeFailed_class =
3387                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeFailed"));
3388         CHECK(LDKEvent_ProbeFailed_class != NULL);
3389         LDKEvent_ProbeFailed_meth = (*env)->GetMethodID(env, LDKEvent_ProbeFailed_class, "<init>", "([B[B[JJ)V");
3390         CHECK(LDKEvent_ProbeFailed_meth != NULL);
3391         LDKEvent_PendingHTLCsForwardable_class =
3392                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
3393         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
3394         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
3395         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
3396         LDKEvent_HTLCIntercepted_class =
3397                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCIntercepted"));
3398         CHECK(LDKEvent_HTLCIntercepted_class != NULL);
3399         LDKEvent_HTLCIntercepted_meth = (*env)->GetMethodID(env, LDKEvent_HTLCIntercepted_class, "<init>", "([BJ[BJJ)V");
3400         CHECK(LDKEvent_HTLCIntercepted_meth != NULL);
3401         LDKEvent_SpendableOutputs_class =
3402                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
3403         CHECK(LDKEvent_SpendableOutputs_class != NULL);
3404         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
3405         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
3406         LDKEvent_PaymentForwarded_class =
3407                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
3408         CHECK(LDKEvent_PaymentForwarded_class != NULL);
3409         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "([B[BJZ)V");
3410         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
3411         LDKEvent_ChannelReady_class =
3412                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelReady"));
3413         CHECK(LDKEvent_ChannelReady_class != NULL);
3414         LDKEvent_ChannelReady_meth = (*env)->GetMethodID(env, LDKEvent_ChannelReady_class, "<init>", "([B[B[BJ)V");
3415         CHECK(LDKEvent_ChannelReady_meth != NULL);
3416         LDKEvent_ChannelClosed_class =
3417                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
3418         CHECK(LDKEvent_ChannelClosed_class != NULL);
3419         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([B[BJ)V");
3420         CHECK(LDKEvent_ChannelClosed_meth != NULL);
3421         LDKEvent_DiscardFunding_class =
3422                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
3423         CHECK(LDKEvent_DiscardFunding_class != NULL);
3424         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
3425         CHECK(LDKEvent_DiscardFunding_meth != NULL);
3426         LDKEvent_OpenChannelRequest_class =
3427                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
3428         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
3429         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
3430         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
3431         LDKEvent_HTLCHandlingFailed_class =
3432                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCHandlingFailed"));
3433         CHECK(LDKEvent_HTLCHandlingFailed_class != NULL);
3434         LDKEvent_HTLCHandlingFailed_meth = (*env)->GetMethodID(env, LDKEvent_HTLCHandlingFailed_class, "<init>", "([BJ)V");
3435         CHECK(LDKEvent_HTLCHandlingFailed_meth != NULL);
3436 }
3437 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3438         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
3439         switch(obj->tag) {
3440                 case LDKEvent_FundingGenerationReady: {
3441                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
3442                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
3443                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
3444                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->funding_generation_ready.counterparty_node_id.compressed_form);
3445                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
3446                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
3447                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
3448                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
3449                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
3450                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->funding_generation_ready.user_channel_id.le_bytes);
3451                         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);
3452                 }
3453                 case LDKEvent_PaymentClaimable: {
3454                         int8_tArray receiver_node_id_arr = (*env)->NewByteArray(env, 33);
3455                         (*env)->SetByteArrayRegion(env, receiver_node_id_arr, 0, 33, obj->payment_claimable.receiver_node_id.compressed_form);
3456                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3457                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimable.payment_hash.data);
3458                         int64_t amount_msat_conv = obj->payment_claimable.amount_msat;
3459                         int64_t purpose_ref = tag_ptr(&obj->payment_claimable.purpose, false);
3460                         int8_tArray via_channel_id_arr = (*env)->NewByteArray(env, 32);
3461                         (*env)->SetByteArrayRegion(env, via_channel_id_arr, 0, 32, obj->payment_claimable.via_channel_id.data);
3462                         int64_t via_user_channel_id_ref = tag_ptr(&obj->payment_claimable.via_user_channel_id, false);
3463                         return (*env)->NewObject(env, LDKEvent_PaymentClaimable_class, LDKEvent_PaymentClaimable_meth, receiver_node_id_arr, payment_hash_arr, amount_msat_conv, purpose_ref, via_channel_id_arr, via_user_channel_id_ref);
3464                 }
3465                 case LDKEvent_PaymentClaimed: {
3466                         int8_tArray receiver_node_id_arr = (*env)->NewByteArray(env, 33);
3467                         (*env)->SetByteArrayRegion(env, receiver_node_id_arr, 0, 33, obj->payment_claimed.receiver_node_id.compressed_form);
3468                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3469                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimed.payment_hash.data);
3470                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
3471                         int64_t purpose_ref = tag_ptr(&obj->payment_claimed.purpose, false);
3472                         return (*env)->NewObject(env, LDKEvent_PaymentClaimed_class, LDKEvent_PaymentClaimed_meth, receiver_node_id_arr, payment_hash_arr, amount_msat_conv, purpose_ref);
3473                 }
3474                 case LDKEvent_PaymentSent: {
3475                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3476                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
3477                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
3478                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
3479                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3480                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
3481                         int64_t fee_paid_msat_ref = tag_ptr(&obj->payment_sent.fee_paid_msat, false);
3482                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
3483                 }
3484                 case LDKEvent_PaymentFailed: {
3485                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3486                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
3487                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3488                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
3489                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
3490                 }
3491                 case LDKEvent_PaymentPathSuccessful: {
3492                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3493                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
3494                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3495                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
3496                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
3497                         int64_tArray path_arr = NULL;
3498                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3499                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3500                         for (size_t k = 0; k < path_var.datalen; k++) {
3501                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3502                                 int64_t path_conv_10_ref = 0;
3503                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3504                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3505                                 path_arr_ptr[k] = path_conv_10_ref;
3506                         }
3507                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3508                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
3509                 }
3510                 case LDKEvent_PaymentPathFailed: {
3511                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3512                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
3513                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3514                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
3515                         jboolean payment_failed_permanently_conv = obj->payment_path_failed.payment_failed_permanently;
3516                         int64_t failure_ref = tag_ptr(&obj->payment_path_failed.failure, false);
3517                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
3518                         int64_tArray path_arr = NULL;
3519                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3520                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3521                         for (size_t k = 0; k < path_var.datalen; k++) {
3522                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3523                                 int64_t path_conv_10_ref = 0;
3524                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3525                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3526                                 path_arr_ptr[k] = path_conv_10_ref;
3527                         }
3528                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3529                         int64_t short_channel_id_ref = tag_ptr(&obj->payment_path_failed.short_channel_id, false);
3530                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
3531                         int64_t retry_ref = 0;
3532                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
3533                         retry_ref = tag_ptr(retry_var.inner, false);
3534                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, payment_failed_permanently_conv, failure_ref, path_arr, short_channel_id_ref, retry_ref);
3535                 }
3536                 case LDKEvent_ProbeSuccessful: {
3537                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3538                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_successful.payment_id.data);
3539                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3540                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_successful.payment_hash.data);
3541                         LDKCVec_RouteHopZ path_var = obj->probe_successful.path;
3542                         int64_tArray path_arr = NULL;
3543                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3544                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3545                         for (size_t k = 0; k < path_var.datalen; k++) {
3546                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3547                                 int64_t path_conv_10_ref = 0;
3548                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3549                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3550                                 path_arr_ptr[k] = path_conv_10_ref;
3551                         }
3552                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3553                         return (*env)->NewObject(env, LDKEvent_ProbeSuccessful_class, LDKEvent_ProbeSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
3554                 }
3555                 case LDKEvent_ProbeFailed: {
3556                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3557                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_failed.payment_id.data);
3558                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3559                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_failed.payment_hash.data);
3560                         LDKCVec_RouteHopZ path_var = obj->probe_failed.path;
3561                         int64_tArray path_arr = NULL;
3562                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3563                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3564                         for (size_t k = 0; k < path_var.datalen; k++) {
3565                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3566                                 int64_t path_conv_10_ref = 0;
3567                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3568                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3569                                 path_arr_ptr[k] = path_conv_10_ref;
3570                         }
3571                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3572                         int64_t short_channel_id_ref = tag_ptr(&obj->probe_failed.short_channel_id, false);
3573                         return (*env)->NewObject(env, LDKEvent_ProbeFailed_class, LDKEvent_ProbeFailed_meth, payment_id_arr, payment_hash_arr, path_arr, short_channel_id_ref);
3574                 }
3575                 case LDKEvent_PendingHTLCsForwardable: {
3576                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
3577                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
3578                 }
3579                 case LDKEvent_HTLCIntercepted: {
3580                         int8_tArray intercept_id_arr = (*env)->NewByteArray(env, 32);
3581                         (*env)->SetByteArrayRegion(env, intercept_id_arr, 0, 32, obj->htlc_intercepted.intercept_id.data);
3582                         int64_t requested_next_hop_scid_conv = obj->htlc_intercepted.requested_next_hop_scid;
3583                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3584                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->htlc_intercepted.payment_hash.data);
3585                         int64_t inbound_amount_msat_conv = obj->htlc_intercepted.inbound_amount_msat;
3586                         int64_t expected_outbound_amount_msat_conv = obj->htlc_intercepted.expected_outbound_amount_msat;
3587                         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);
3588                 }
3589                 case LDKEvent_SpendableOutputs: {
3590                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
3591                         int64_tArray outputs_arr = NULL;
3592                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
3593                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
3594                         for (size_t b = 0; b < outputs_var.datalen; b++) {
3595                                 int64_t outputs_conv_27_ref = tag_ptr(&outputs_var.data[b], false);
3596                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
3597                         }
3598                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
3599                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
3600                 }
3601                 case LDKEvent_PaymentForwarded: {
3602                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
3603                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->payment_forwarded.prev_channel_id.data);
3604                         int8_tArray next_channel_id_arr = (*env)->NewByteArray(env, 32);
3605                         (*env)->SetByteArrayRegion(env, next_channel_id_arr, 0, 32, obj->payment_forwarded.next_channel_id.data);
3606                         int64_t fee_earned_msat_ref = tag_ptr(&obj->payment_forwarded.fee_earned_msat, false);
3607                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
3608                         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);
3609                 }
3610                 case LDKEvent_ChannelReady: {
3611                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3612                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_ready.channel_id.data);
3613                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
3614                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->channel_ready.user_channel_id.le_bytes);
3615                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
3616                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->channel_ready.counterparty_node_id.compressed_form);
3617                         LDKChannelTypeFeatures channel_type_var = obj->channel_ready.channel_type;
3618                         int64_t channel_type_ref = 0;
3619                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
3620                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
3621                         return (*env)->NewObject(env, LDKEvent_ChannelReady_class, LDKEvent_ChannelReady_meth, channel_id_arr, user_channel_id_arr, counterparty_node_id_arr, channel_type_ref);
3622                 }
3623                 case LDKEvent_ChannelClosed: {
3624                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3625                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
3626                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
3627                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->channel_closed.user_channel_id.le_bytes);
3628                         int64_t reason_ref = tag_ptr(&obj->channel_closed.reason, false);
3629                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_arr, reason_ref);
3630                 }
3631                 case LDKEvent_DiscardFunding: {
3632                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3633                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
3634                         LDKTransaction transaction_var = obj->discard_funding.transaction;
3635                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
3636                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
3637                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
3638                 }
3639                 case LDKEvent_OpenChannelRequest: {
3640                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
3641                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
3642                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
3643                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
3644                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
3645                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
3646                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
3647                         int64_t channel_type_ref = 0;
3648                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
3649                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
3650                         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);
3651                 }
3652                 case LDKEvent_HTLCHandlingFailed: {
3653                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
3654                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->htlc_handling_failed.prev_channel_id.data);
3655                         int64_t failed_next_destination_ref = tag_ptr(&obj->htlc_handling_failed.failed_next_destination, false);
3656                         return (*env)->NewObject(env, LDKEvent_HTLCHandlingFailed_class, LDKEvent_HTLCHandlingFailed_meth, prev_channel_id_arr, failed_next_destination_ref);
3657                 }
3658                 default: abort();
3659         }
3660 }
3661 static jclass LDKCOption_EventZ_Some_class = NULL;
3662 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
3663 static jclass LDKCOption_EventZ_None_class = NULL;
3664 static jmethodID LDKCOption_EventZ_None_meth = NULL;
3665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
3666         LDKCOption_EventZ_Some_class =
3667                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
3668         CHECK(LDKCOption_EventZ_Some_class != NULL);
3669         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
3670         CHECK(LDKCOption_EventZ_Some_meth != NULL);
3671         LDKCOption_EventZ_None_class =
3672                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
3673         CHECK(LDKCOption_EventZ_None_class != NULL);
3674         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
3675         CHECK(LDKCOption_EventZ_None_meth != NULL);
3676 }
3677 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3678         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)untag_ptr(ptr);
3679         switch(obj->tag) {
3680                 case LDKCOption_EventZ_Some: {
3681                         int64_t some_ref = tag_ptr(&obj->some, false);
3682                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
3683                 }
3684                 case LDKCOption_EventZ_None: {
3685                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
3686                 }
3687                 default: abort();
3688         }
3689 }
3690 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3691 CHECK(owner->result_ok);
3692         return COption_EventZ_clone(&*owner->contents.result);
3693 }
3694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3695         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
3696         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
3697         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
3698         int64_t ret_ref = tag_ptr(ret_copy, true);
3699         return ret_ref;
3700 }
3701
3702 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3703 CHECK(!owner->result_ok);
3704         return DecodeError_clone(&*owner->contents.err);
3705 }
3706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3707         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
3708         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3709         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
3710         int64_t ret_ref = tag_ptr(ret_copy, true);
3711         return ret_ref;
3712 }
3713
3714 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
3715 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
3716 static jclass LDKErrorAction_IgnoreError_class = NULL;
3717 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
3718 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
3719 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
3720 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
3721 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
3722 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
3723 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
3724 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
3725 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
3726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
3727         LDKErrorAction_DisconnectPeer_class =
3728                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
3729         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
3730         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
3731         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
3732         LDKErrorAction_IgnoreError_class =
3733                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
3734         CHECK(LDKErrorAction_IgnoreError_class != NULL);
3735         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
3736         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
3737         LDKErrorAction_IgnoreAndLog_class =
3738                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
3739         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
3740         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
3741         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
3742         LDKErrorAction_IgnoreDuplicateGossip_class =
3743                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
3744         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
3745         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
3746         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
3747         LDKErrorAction_SendErrorMessage_class =
3748                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
3749         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
3750         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
3751         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
3752         LDKErrorAction_SendWarningMessage_class =
3753                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
3754         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
3755         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
3756         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
3757 }
3758 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3759         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
3760         switch(obj->tag) {
3761                 case LDKErrorAction_DisconnectPeer: {
3762                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
3763                         int64_t msg_ref = 0;
3764                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3765                         msg_ref = tag_ptr(msg_var.inner, false);
3766                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
3767                 }
3768                 case LDKErrorAction_IgnoreError: {
3769                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
3770                 }
3771                 case LDKErrorAction_IgnoreAndLog: {
3772                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
3773                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
3774                 }
3775                 case LDKErrorAction_IgnoreDuplicateGossip: {
3776                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
3777                 }
3778                 case LDKErrorAction_SendErrorMessage: {
3779                         LDKErrorMessage msg_var = obj->send_error_message.msg;
3780                         int64_t msg_ref = 0;
3781                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3782                         msg_ref = tag_ptr(msg_var.inner, false);
3783                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
3784                 }
3785                 case LDKErrorAction_SendWarningMessage: {
3786                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
3787                         int64_t msg_ref = 0;
3788                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3789                         msg_ref = tag_ptr(msg_var.inner, false);
3790                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
3791                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
3792                 }
3793                 default: abort();
3794         }
3795 }
3796 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
3797 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
3798 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
3799 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
3800 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
3801 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
3802 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
3803 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
3804 static jclass LDKMessageSendEvent_SendChannelReady_class = NULL;
3805 static jmethodID LDKMessageSendEvent_SendChannelReady_meth = NULL;
3806 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
3807 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
3808 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
3809 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
3810 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
3811 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
3812 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
3813 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
3814 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
3815 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
3816 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
3817 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
3818 static jclass LDKMessageSendEvent_SendChannelAnnouncement_class = NULL;
3819 static jmethodID LDKMessageSendEvent_SendChannelAnnouncement_meth = NULL;
3820 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
3821 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
3822 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
3823 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
3824 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
3825 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
3826 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
3827 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
3828 static jclass LDKMessageSendEvent_HandleError_class = NULL;
3829 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
3830 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
3831 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
3832 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
3833 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
3834 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
3835 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
3836 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
3837 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
3838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
3839         LDKMessageSendEvent_SendAcceptChannel_class =
3840                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
3841         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
3842         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
3843         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
3844         LDKMessageSendEvent_SendOpenChannel_class =
3845                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
3846         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
3847         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
3848         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
3849         LDKMessageSendEvent_SendFundingCreated_class =
3850                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
3851         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
3852         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
3853         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
3854         LDKMessageSendEvent_SendFundingSigned_class =
3855                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
3856         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
3857         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
3858         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
3859         LDKMessageSendEvent_SendChannelReady_class =
3860                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReady"));
3861         CHECK(LDKMessageSendEvent_SendChannelReady_class != NULL);
3862         LDKMessageSendEvent_SendChannelReady_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReady_class, "<init>", "([BJ)V");
3863         CHECK(LDKMessageSendEvent_SendChannelReady_meth != NULL);
3864         LDKMessageSendEvent_SendAnnouncementSignatures_class =
3865                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
3866         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
3867         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
3868         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
3869         LDKMessageSendEvent_UpdateHTLCs_class =
3870                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
3871         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
3872         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
3873         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
3874         LDKMessageSendEvent_SendRevokeAndACK_class =
3875                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
3876         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
3877         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
3878         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
3879         LDKMessageSendEvent_SendClosingSigned_class =
3880                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
3881         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
3882         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
3883         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
3884         LDKMessageSendEvent_SendShutdown_class =
3885                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
3886         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
3887         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
3888         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
3889         LDKMessageSendEvent_SendChannelReestablish_class =
3890                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
3891         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
3892         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
3893         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
3894         LDKMessageSendEvent_SendChannelAnnouncement_class =
3895                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelAnnouncement"));
3896         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_class != NULL);
3897         LDKMessageSendEvent_SendChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelAnnouncement_class, "<init>", "([BJJ)V");
3898         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_meth != NULL);
3899         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
3900                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
3901         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
3902         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
3903         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
3904         LDKMessageSendEvent_BroadcastChannelUpdate_class =
3905                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
3906         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
3907         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
3908         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
3909         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
3910                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
3911         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
3912         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
3913         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
3914         LDKMessageSendEvent_SendChannelUpdate_class =
3915                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
3916         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
3917         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
3918         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
3919         LDKMessageSendEvent_HandleError_class =
3920                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
3921         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
3922         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
3923         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
3924         LDKMessageSendEvent_SendChannelRangeQuery_class =
3925                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
3926         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
3927         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
3928         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
3929         LDKMessageSendEvent_SendShortIdsQuery_class =
3930                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
3931         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
3932         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
3933         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
3934         LDKMessageSendEvent_SendReplyChannelRange_class =
3935                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
3936         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
3937         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
3938         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
3939         LDKMessageSendEvent_SendGossipTimestampFilter_class =
3940                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
3941         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
3942         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
3943         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
3944 }
3945 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3946         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
3947         switch(obj->tag) {
3948                 case LDKMessageSendEvent_SendAcceptChannel: {
3949                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3950                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
3951                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
3952                         int64_t msg_ref = 0;
3953                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3954                         msg_ref = tag_ptr(msg_var.inner, false);
3955                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
3956                 }
3957                 case LDKMessageSendEvent_SendOpenChannel: {
3958                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3959                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
3960                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
3961                         int64_t msg_ref = 0;
3962                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3963                         msg_ref = tag_ptr(msg_var.inner, false);
3964                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
3965                 }
3966                 case LDKMessageSendEvent_SendFundingCreated: {
3967                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3968                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
3969                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
3970                         int64_t msg_ref = 0;
3971                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3972                         msg_ref = tag_ptr(msg_var.inner, false);
3973                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
3974                 }
3975                 case LDKMessageSendEvent_SendFundingSigned: {
3976                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3977                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
3978                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
3979                         int64_t msg_ref = 0;
3980                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3981                         msg_ref = tag_ptr(msg_var.inner, false);
3982                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
3983                 }
3984                 case LDKMessageSendEvent_SendChannelReady: {
3985                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3986                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_ready.node_id.compressed_form);
3987                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
3988                         int64_t msg_ref = 0;
3989                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3990                         msg_ref = tag_ptr(msg_var.inner, false);
3991                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReady_class, LDKMessageSendEvent_SendChannelReady_meth, node_id_arr, msg_ref);
3992                 }
3993                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
3994                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3995                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
3996                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
3997                         int64_t msg_ref = 0;
3998                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3999                         msg_ref = tag_ptr(msg_var.inner, false);
4000                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
4001                 }
4002                 case LDKMessageSendEvent_UpdateHTLCs: {
4003                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4004                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
4005                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
4006                         int64_t updates_ref = 0;
4007                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
4008                         updates_ref = tag_ptr(updates_var.inner, false);
4009                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
4010                 }
4011                 case LDKMessageSendEvent_SendRevokeAndACK: {
4012                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4013                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
4014                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
4015                         int64_t msg_ref = 0;
4016                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4017                         msg_ref = tag_ptr(msg_var.inner, false);
4018                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
4019                 }
4020                 case LDKMessageSendEvent_SendClosingSigned: {
4021                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4022                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
4023                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
4024                         int64_t msg_ref = 0;
4025                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4026                         msg_ref = tag_ptr(msg_var.inner, false);
4027                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
4028                 }
4029                 case LDKMessageSendEvent_SendShutdown: {
4030                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4031                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
4032                         LDKShutdown msg_var = obj->send_shutdown.msg;
4033                         int64_t msg_ref = 0;
4034                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4035                         msg_ref = tag_ptr(msg_var.inner, false);
4036                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
4037                 }
4038                 case LDKMessageSendEvent_SendChannelReestablish: {
4039                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4040                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
4041                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
4042                         int64_t msg_ref = 0;
4043                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4044                         msg_ref = tag_ptr(msg_var.inner, false);
4045                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
4046                 }
4047                 case LDKMessageSendEvent_SendChannelAnnouncement: {
4048                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4049                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_announcement.node_id.compressed_form);
4050                         LDKChannelAnnouncement msg_var = obj->send_channel_announcement.msg;
4051                         int64_t msg_ref = 0;
4052                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4053                         msg_ref = tag_ptr(msg_var.inner, false);
4054                         LDKChannelUpdate update_msg_var = obj->send_channel_announcement.update_msg;
4055                         int64_t update_msg_ref = 0;
4056                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
4057                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
4058                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelAnnouncement_class, LDKMessageSendEvent_SendChannelAnnouncement_meth, node_id_arr, msg_ref, update_msg_ref);
4059                 }
4060                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
4061                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
4062                         int64_t msg_ref = 0;
4063                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4064                         msg_ref = tag_ptr(msg_var.inner, false);
4065                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
4066                         int64_t update_msg_ref = 0;
4067                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
4068                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
4069                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
4070                 }
4071                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
4072                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
4073                         int64_t msg_ref = 0;
4074                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4075                         msg_ref = tag_ptr(msg_var.inner, false);
4076                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
4077                 }
4078                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
4079                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
4080                         int64_t msg_ref = 0;
4081                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4082                         msg_ref = tag_ptr(msg_var.inner, false);
4083                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
4084                 }
4085                 case LDKMessageSendEvent_SendChannelUpdate: {
4086                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4087                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
4088                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
4089                         int64_t msg_ref = 0;
4090                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4091                         msg_ref = tag_ptr(msg_var.inner, false);
4092                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
4093                 }
4094                 case LDKMessageSendEvent_HandleError: {
4095                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4096                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
4097                         int64_t action_ref = tag_ptr(&obj->handle_error.action, false);
4098                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
4099                 }
4100                 case LDKMessageSendEvent_SendChannelRangeQuery: {
4101                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4102                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
4103                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
4104                         int64_t msg_ref = 0;
4105                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4106                         msg_ref = tag_ptr(msg_var.inner, false);
4107                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
4108                 }
4109                 case LDKMessageSendEvent_SendShortIdsQuery: {
4110                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4111                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
4112                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
4113                         int64_t msg_ref = 0;
4114                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4115                         msg_ref = tag_ptr(msg_var.inner, false);
4116                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
4117                 }
4118                 case LDKMessageSendEvent_SendReplyChannelRange: {
4119                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4120                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
4121                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
4122                         int64_t msg_ref = 0;
4123                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4124                         msg_ref = tag_ptr(msg_var.inner, false);
4125                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
4126                 }
4127                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
4128                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4129                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
4130                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
4131                         int64_t msg_ref = 0;
4132                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4133                         msg_ref = tag_ptr(msg_var.inner, false);
4134                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
4135                 }
4136                 default: abort();
4137         }
4138 }
4139 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
4140         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
4141         for (size_t i = 0; i < ret.datalen; i++) {
4142                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
4143         }
4144         return ret;
4145 }
4146 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
4147         return owner->a;
4148 }
4149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4150         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
4151         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
4152         return ret_conv;
4153 }
4154
4155 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
4156         return owner->b;
4157 }
4158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4159         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
4160         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
4161         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4162         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4163         return ret_arr;
4164 }
4165
4166 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
4167         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
4168         for (size_t i = 0; i < ret.datalen; i++) {
4169                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
4170         }
4171         return ret;
4172 }
4173 static inline struct LDKThirtyTwoBytes C2Tuple_TxidBlockHashZ_get_a(LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR owner){
4174         return ThirtyTwoBytes_clone(&owner->a);
4175 }
4176 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4177         LDKC2Tuple_TxidBlockHashZ* owner_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(owner);
4178         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4179         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidBlockHashZ_get_a(owner_conv).data);
4180         return ret_arr;
4181 }
4182
4183 static inline struct LDKThirtyTwoBytes C2Tuple_TxidBlockHashZ_get_b(LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR owner){
4184         return ThirtyTwoBytes_clone(&owner->b);
4185 }
4186 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4187         LDKC2Tuple_TxidBlockHashZ* owner_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(owner);
4188         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4189         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidBlockHashZ_get_b(owner_conv).data);
4190         return ret_arr;
4191 }
4192
4193 static inline LDKCVec_C2Tuple_TxidBlockHashZZ CVec_C2Tuple_TxidBlockHashZZ_clone(const LDKCVec_C2Tuple_TxidBlockHashZZ *orig) {
4194         LDKCVec_C2Tuple_TxidBlockHashZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ) * orig->datalen, "LDKCVec_C2Tuple_TxidBlockHashZZ clone bytes"), .datalen = orig->datalen };
4195         for (size_t i = 0; i < ret.datalen; i++) {
4196                 ret.data[i] = C2Tuple_TxidBlockHashZ_clone(&orig->data[i]);
4197         }
4198         return ret;
4199 }
4200 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
4201 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
4202 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
4203 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
4204 static jclass LDKMonitorEvent_Completed_class = NULL;
4205 static jmethodID LDKMonitorEvent_Completed_meth = NULL;
4206 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
4207 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
4208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
4209         LDKMonitorEvent_HTLCEvent_class =
4210                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
4211         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
4212         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
4213         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
4214         LDKMonitorEvent_CommitmentTxConfirmed_class =
4215                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
4216         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
4217         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
4218         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
4219         LDKMonitorEvent_Completed_class =
4220                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$Completed"));
4221         CHECK(LDKMonitorEvent_Completed_class != NULL);
4222         LDKMonitorEvent_Completed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_Completed_class, "<init>", "(JJ)V");
4223         CHECK(LDKMonitorEvent_Completed_meth != NULL);
4224         LDKMonitorEvent_UpdateFailed_class =
4225                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
4226         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
4227         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
4228         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
4229 }
4230 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4231         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
4232         switch(obj->tag) {
4233                 case LDKMonitorEvent_HTLCEvent: {
4234                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
4235                         int64_t htlc_event_ref = 0;
4236                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
4237                         htlc_event_ref = tag_ptr(htlc_event_var.inner, false);
4238                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
4239                 }
4240                 case LDKMonitorEvent_CommitmentTxConfirmed: {
4241                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
4242                         int64_t commitment_tx_confirmed_ref = 0;
4243                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
4244                         commitment_tx_confirmed_ref = tag_ptr(commitment_tx_confirmed_var.inner, false);
4245                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
4246                 }
4247                 case LDKMonitorEvent_Completed: {
4248                         LDKOutPoint funding_txo_var = obj->completed.funding_txo;
4249                         int64_t funding_txo_ref = 0;
4250                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4251                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
4252                         int64_t monitor_update_id_conv = obj->completed.monitor_update_id;
4253                         return (*env)->NewObject(env, LDKMonitorEvent_Completed_class, LDKMonitorEvent_Completed_meth, funding_txo_ref, monitor_update_id_conv);
4254                 }
4255                 case LDKMonitorEvent_UpdateFailed: {
4256                         LDKOutPoint update_failed_var = obj->update_failed;
4257                         int64_t update_failed_ref = 0;
4258                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
4259                         update_failed_ref = tag_ptr(update_failed_var.inner, false);
4260                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
4261                 }
4262                 default: abort();
4263         }
4264 }
4265 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
4266         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
4267         for (size_t i = 0; i < ret.datalen; i++) {
4268                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
4269         }
4270         return ret;
4271 }
4272 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
4273         LDKOutPoint ret = owner->a;
4274         ret.is_owned = false;
4275         return ret;
4276 }
4277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4278         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
4279         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
4280         int64_t ret_ref = 0;
4281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4282         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4283         return ret_ref;
4284 }
4285
4286 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
4287         return CVec_MonitorEventZ_clone(&owner->b);
4288 }
4289 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4290         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
4291         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
4292         int64_tArray ret_arr = NULL;
4293         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4294         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4295         for (size_t o = 0; o < ret_var.datalen; o++) {
4296                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4297                 *ret_conv_14_copy = ret_var.data[o];
4298                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
4299                 ret_arr_ptr[o] = ret_conv_14_ref;
4300         }
4301         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4302         FREE(ret_var.data);
4303         return ret_arr;
4304 }
4305
4306 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
4307         return owner->c;
4308 }
4309 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
4310         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
4311         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
4312         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form);
4313         return ret_arr;
4314 }
4315
4316 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
4317         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
4318         for (size_t i = 0; i < ret.datalen; i++) {
4319                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
4320         }
4321         return ret;
4322 }
4323 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
4324         LDKFixedPenaltyScorer ret = *owner->contents.result;
4325         ret.is_owned = false;
4326         return ret;
4327 }
4328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4329         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
4330         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
4331         int64_t ret_ref = 0;
4332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4333         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4334         return ret_ref;
4335 }
4336
4337 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
4338 CHECK(!owner->result_ok);
4339         return DecodeError_clone(&*owner->contents.err);
4340 }
4341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4342         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
4343         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4344         *ret_copy = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
4345         int64_t ret_ref = tag_ptr(ret_copy, true);
4346         return ret_ref;
4347 }
4348
4349 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
4350         return owner->a;
4351 }
4352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4353         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
4354         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
4355         return ret_conv;
4356 }
4357
4358 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
4359         return owner->b;
4360 }
4361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4362         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
4363         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
4364         return ret_conv;
4365 }
4366
4367 static jclass LDKCOption_C2Tuple_u64u64ZZ_Some_class = NULL;
4368 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_Some_meth = NULL;
4369 static jclass LDKCOption_C2Tuple_u64u64ZZ_None_class = NULL;
4370 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_None_meth = NULL;
4371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1u64u64ZZ_init (JNIEnv *env, jclass clz) {
4372         LDKCOption_C2Tuple_u64u64ZZ_Some_class =
4373                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$Some"));
4374         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_class != NULL);
4375         LDKCOption_C2Tuple_u64u64ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, "<init>", "(J)V");
4376         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_meth != NULL);
4377         LDKCOption_C2Tuple_u64u64ZZ_None_class =
4378                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$None"));
4379         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_class != NULL);
4380         LDKCOption_C2Tuple_u64u64ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, "<init>", "()V");
4381         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_meth != NULL);
4382 }
4383 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1u64u64ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4384         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(ptr);
4385         switch(obj->tag) {
4386                 case LDKCOption_C2Tuple_u64u64ZZ_Some: {
4387                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
4388                         *some_conv = obj->some;
4389                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
4390                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, LDKCOption_C2Tuple_u64u64ZZ_Some_meth, tag_ptr(some_conv, true));
4391                 }
4392                 case LDKCOption_C2Tuple_u64u64ZZ_None: {
4393                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, LDKCOption_C2Tuple_u64u64ZZ_None_meth);
4394                 }
4395                 default: abort();
4396         }
4397 }
4398 static inline struct LDKEightU16s C2Tuple_Z_get_a(LDKC2Tuple_Z *NONNULL_PTR owner){
4399         return owner->a;
4400 }
4401 JNIEXPORT int16_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4402         LDKC2Tuple_Z* owner_conv = (LDKC2Tuple_Z*)untag_ptr(owner);
4403         int16_tArray ret_arr = (*env)->NewShortArray(env, 8);
4404         (*env)->SetShortArrayRegion(env, ret_arr, 0, 8, C2Tuple_Z_get_a(owner_conv).data);
4405         return ret_arr;
4406 }
4407
4408 static inline struct LDKEightU16s C2Tuple_Z_get_b(LDKC2Tuple_Z *NONNULL_PTR owner){
4409         return owner->b;
4410 }
4411 JNIEXPORT int16_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4412         LDKC2Tuple_Z* owner_conv = (LDKC2Tuple_Z*)untag_ptr(owner);
4413         int16_tArray ret_arr = (*env)->NewShortArray(env, 8);
4414         (*env)->SetShortArrayRegion(env, ret_arr, 0, 8, C2Tuple_Z_get_b(owner_conv).data);
4415         return ret_arr;
4416 }
4417
4418 static inline struct LDKEightU16s C2Tuple__u168_u168Z_get_a(LDKC2Tuple__u168_u168Z *NONNULL_PTR owner){
4419         return owner->a;
4420 }
4421 JNIEXPORT int16_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4422         LDKC2Tuple__u168_u168Z* owner_conv = (LDKC2Tuple__u168_u168Z*)untag_ptr(owner);
4423         int16_tArray ret_arr = (*env)->NewShortArray(env, 8);
4424         (*env)->SetShortArrayRegion(env, ret_arr, 0, 8, C2Tuple__u168_u168Z_get_a(owner_conv).data);
4425         return ret_arr;
4426 }
4427
4428 static inline struct LDKEightU16s C2Tuple__u168_u168Z_get_b(LDKC2Tuple__u168_u168Z *NONNULL_PTR owner){
4429         return owner->b;
4430 }
4431 JNIEXPORT int16_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4432         LDKC2Tuple__u168_u168Z* owner_conv = (LDKC2Tuple__u168_u168Z*)untag_ptr(owner);
4433         int16_tArray ret_arr = (*env)->NewShortArray(env, 8);
4434         (*env)->SetShortArrayRegion(env, ret_arr, 0, 8, C2Tuple__u168_u168Z_get_b(owner_conv).data);
4435         return ret_arr;
4436 }
4437
4438 static jclass LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_class = NULL;
4439 static jmethodID LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_meth = NULL;
4440 static jclass LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_class = NULL;
4441 static jmethodID LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_meth = NULL;
4442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1EightU16sEightU16sZZ_init (JNIEnv *env, jclass clz) {
4443         LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_class =
4444                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_EightU16sEightU16sZZ$Some"));
4445         CHECK(LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_class != NULL);
4446         LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_class, "<init>", "(J)V");
4447         CHECK(LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_meth != NULL);
4448         LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_class =
4449                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_EightU16sEightU16sZZ$None"));
4450         CHECK(LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_class != NULL);
4451         LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_class, "<init>", "()V");
4452         CHECK(LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_meth != NULL);
4453 }
4454 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1EightU16sEightU16sZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4455         LDKCOption_C2Tuple_EightU16sEightU16sZZ *obj = (LDKCOption_C2Tuple_EightU16sEightU16sZZ*)untag_ptr(ptr);
4456         switch(obj->tag) {
4457                 case LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some: {
4458                         LDKC2Tuple__u168_u168Z* some_conv = MALLOC(sizeof(LDKC2Tuple__u168_u168Z), "LDKC2Tuple__u168_u168Z");
4459                         *some_conv = obj->some;
4460                         *some_conv = C2Tuple__u168_u168Z_clone(some_conv);
4461                         return (*env)->NewObject(env, LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_class, LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_meth, tag_ptr(some_conv, true));
4462                 }
4463                 case LDKCOption_C2Tuple_EightU16sEightU16sZZ_None: {
4464                         return (*env)->NewObject(env, LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_class, LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_meth);
4465                 }
4466                 default: abort();
4467         }
4468 }
4469 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
4470         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
4471         for (size_t i = 0; i < ret.datalen; i++) {
4472                 ret.data[i] = NodeId_clone(&orig->data[i]);
4473         }
4474         return ret;
4475 }
4476 typedef struct LDKLogger_JCalls {
4477         atomic_size_t refcnt;
4478         JavaVM *vm;
4479         jweak o;
4480         jmethodID log_meth;
4481 } LDKLogger_JCalls;
4482 static void LDKLogger_JCalls_free(void* this_arg) {
4483         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4484         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4485                 JNIEnv *env;
4486                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4487                 if (get_jenv_res == JNI_EDETACHED) {
4488                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4489                 } else {
4490                         DO_ASSERT(get_jenv_res == JNI_OK);
4491                 }
4492                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4493                 if (get_jenv_res == JNI_EDETACHED) {
4494                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4495                 }
4496                 FREE(j_calls);
4497         }
4498 }
4499 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
4500         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4501         JNIEnv *env;
4502         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4503         if (get_jenv_res == JNI_EDETACHED) {
4504                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4505         } else {
4506                 DO_ASSERT(get_jenv_res == JNI_OK);
4507         }
4508         LDKRecord record_var = *record;
4509         int64_t record_ref = 0;
4510         record_var = Record_clone(&record_var);
4511         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
4512         record_ref = tag_ptr(record_var.inner, record_var.is_owned);
4513         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4514         CHECK(obj != NULL);
4515         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
4516         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4517                 (*env)->ExceptionDescribe(env);
4518                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4519         }
4520         if (get_jenv_res == JNI_EDETACHED) {
4521                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4522         }
4523 }
4524 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4525         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4526         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4527 }
4528 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4529         jclass c = (*env)->GetObjectClass(env, o);
4530         CHECK(c != NULL);
4531         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4532         atomic_init(&calls->refcnt, 1);
4533         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4534         calls->o = (*env)->NewWeakGlobalRef(env, o);
4535         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
4536         CHECK(calls->log_meth != NULL);
4537
4538         LDKLogger ret = {
4539                 .this_arg = (void*) calls,
4540                 .log = log_LDKLogger_jcall,
4541                 .free = LDKLogger_JCalls_free,
4542         };
4543         return ret;
4544 }
4545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4546         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4547         *res_ptr = LDKLogger_init(env, clz, o);
4548         return tag_ptr(res_ptr, true);
4549 }
4550 static inline struct LDKProbabilisticScorer CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
4551         LDKProbabilisticScorer ret = *owner->contents.result;
4552         ret.is_owned = false;
4553         return ret;
4554 }
4555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4556         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
4557         LDKProbabilisticScorer ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
4558         int64_t ret_ref = 0;
4559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4560         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4561         return ret_ref;
4562 }
4563
4564 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
4565 CHECK(!owner->result_ok);
4566         return DecodeError_clone(&*owner->contents.err);
4567 }
4568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4569         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
4570         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4571         *ret_copy = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
4572         int64_t ret_ref = tag_ptr(ret_copy, true);
4573         return ret_ref;
4574 }
4575
4576 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4577         LDKInitFeatures ret = *owner->contents.result;
4578         ret.is_owned = false;
4579         return ret;
4580 }
4581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4582         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
4583         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
4584         int64_t ret_ref = 0;
4585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4586         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4587         return ret_ref;
4588 }
4589
4590 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4591 CHECK(!owner->result_ok);
4592         return DecodeError_clone(&*owner->contents.err);
4593 }
4594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4595         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
4596         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4597         *ret_copy = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
4598         int64_t ret_ref = tag_ptr(ret_copy, true);
4599         return ret_ref;
4600 }
4601
4602 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4603         LDKChannelFeatures ret = *owner->contents.result;
4604         ret.is_owned = false;
4605         return ret;
4606 }
4607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4608         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
4609         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
4610         int64_t ret_ref = 0;
4611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4612         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4613         return ret_ref;
4614 }
4615
4616 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4617 CHECK(!owner->result_ok);
4618         return DecodeError_clone(&*owner->contents.err);
4619 }
4620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4621         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
4622         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4623         *ret_copy = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
4624         int64_t ret_ref = tag_ptr(ret_copy, true);
4625         return ret_ref;
4626 }
4627
4628 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4629         LDKNodeFeatures ret = *owner->contents.result;
4630         ret.is_owned = false;
4631         return ret;
4632 }
4633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4634         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
4635         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
4636         int64_t ret_ref = 0;
4637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4638         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4639         return ret_ref;
4640 }
4641
4642 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4643 CHECK(!owner->result_ok);
4644         return DecodeError_clone(&*owner->contents.err);
4645 }
4646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4647         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
4648         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4649         *ret_copy = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
4650         int64_t ret_ref = tag_ptr(ret_copy, true);
4651         return ret_ref;
4652 }
4653
4654 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4655         LDKInvoiceFeatures ret = *owner->contents.result;
4656         ret.is_owned = false;
4657         return ret;
4658 }
4659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4660         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
4661         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
4662         int64_t ret_ref = 0;
4663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4664         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4665         return ret_ref;
4666 }
4667
4668 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4669 CHECK(!owner->result_ok);
4670         return DecodeError_clone(&*owner->contents.err);
4671 }
4672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4673         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
4674         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4675         *ret_copy = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
4676         int64_t ret_ref = tag_ptr(ret_copy, true);
4677         return ret_ref;
4678 }
4679
4680 static inline struct LDKBlindedHopFeatures CResult_BlindedHopFeaturesDecodeErrorZ_get_ok(LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR owner){
4681         LDKBlindedHopFeatures ret = *owner->contents.result;
4682         ret.is_owned = false;
4683         return ret;
4684 }
4685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4686         LDKCResult_BlindedHopFeaturesDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(owner);
4687         LDKBlindedHopFeatures ret_var = CResult_BlindedHopFeaturesDecodeErrorZ_get_ok(owner_conv);
4688         int64_t ret_ref = 0;
4689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4690         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4691         return ret_ref;
4692 }
4693
4694 static inline struct LDKDecodeError CResult_BlindedHopFeaturesDecodeErrorZ_get_err(LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR owner){
4695 CHECK(!owner->result_ok);
4696         return DecodeError_clone(&*owner->contents.err);
4697 }
4698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4699         LDKCResult_BlindedHopFeaturesDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(owner);
4700         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4701         *ret_copy = CResult_BlindedHopFeaturesDecodeErrorZ_get_err(owner_conv);
4702         int64_t ret_ref = tag_ptr(ret_copy, true);
4703         return ret_ref;
4704 }
4705
4706 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4707         LDKChannelTypeFeatures ret = *owner->contents.result;
4708         ret.is_owned = false;
4709         return ret;
4710 }
4711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4712         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
4713         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
4714         int64_t ret_ref = 0;
4715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4716         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4717         return ret_ref;
4718 }
4719
4720 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4721 CHECK(!owner->result_ok);
4722         return DecodeError_clone(&*owner->contents.err);
4723 }
4724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4725         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
4726         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4727         *ret_copy = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
4728         int64_t ret_ref = tag_ptr(ret_copy, true);
4729         return ret_ref;
4730 }
4731
4732 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4733         LDKNodeId ret = *owner->contents.result;
4734         ret.is_owned = false;
4735         return ret;
4736 }
4737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4738         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4739         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
4740         int64_t ret_ref = 0;
4741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4742         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4743         return ret_ref;
4744 }
4745
4746 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4747 CHECK(!owner->result_ok);
4748         return DecodeError_clone(&*owner->contents.err);
4749 }
4750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4751         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4752         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4753         *ret_copy = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
4754         int64_t ret_ref = tag_ptr(ret_copy, true);
4755         return ret_ref;
4756 }
4757
4758 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4759 CHECK(owner->result_ok);
4760         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
4761 }
4762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4763         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4764         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
4765         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
4766         int64_t ret_ref = tag_ptr(ret_copy, true);
4767         return ret_ref;
4768 }
4769
4770 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4771 CHECK(!owner->result_ok);
4772         return DecodeError_clone(&*owner->contents.err);
4773 }
4774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4775         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4776         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4777         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
4778         int64_t ret_ref = tag_ptr(ret_copy, true);
4779         return ret_ref;
4780 }
4781
4782 static inline struct LDKTxOut CResult_TxOutUtxoLookupErrorZ_get_ok(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR owner){
4783 CHECK(owner->result_ok);
4784         return TxOut_clone(&*owner->contents.result);
4785 }
4786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4787         LDKCResult_TxOutUtxoLookupErrorZ* owner_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(owner);
4788         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
4789         *ret_ref = CResult_TxOutUtxoLookupErrorZ_get_ok(owner_conv);
4790         return tag_ptr(ret_ref, true);
4791 }
4792
4793 static inline enum LDKUtxoLookupError CResult_TxOutUtxoLookupErrorZ_get_err(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR owner){
4794 CHECK(!owner->result_ok);
4795         return UtxoLookupError_clone(&*owner->contents.err);
4796 }
4797 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4798         LDKCResult_TxOutUtxoLookupErrorZ* owner_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(owner);
4799         jclass ret_conv = LDKUtxoLookupError_to_java(env, CResult_TxOutUtxoLookupErrorZ_get_err(owner_conv));
4800         return ret_conv;
4801 }
4802
4803 static jclass LDKUtxoResult_Sync_class = NULL;
4804 static jmethodID LDKUtxoResult_Sync_meth = NULL;
4805 static jclass LDKUtxoResult_Async_class = NULL;
4806 static jmethodID LDKUtxoResult_Async_meth = NULL;
4807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKUtxoResult_init (JNIEnv *env, jclass clz) {
4808         LDKUtxoResult_Sync_class =
4809                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKUtxoResult$Sync"));
4810         CHECK(LDKUtxoResult_Sync_class != NULL);
4811         LDKUtxoResult_Sync_meth = (*env)->GetMethodID(env, LDKUtxoResult_Sync_class, "<init>", "(J)V");
4812         CHECK(LDKUtxoResult_Sync_meth != NULL);
4813         LDKUtxoResult_Async_class =
4814                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKUtxoResult$Async"));
4815         CHECK(LDKUtxoResult_Async_class != NULL);
4816         LDKUtxoResult_Async_meth = (*env)->GetMethodID(env, LDKUtxoResult_Async_class, "<init>", "(J)V");
4817         CHECK(LDKUtxoResult_Async_meth != NULL);
4818 }
4819 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKUtxoResult_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4820         LDKUtxoResult *obj = (LDKUtxoResult*)untag_ptr(ptr);
4821         switch(obj->tag) {
4822                 case LDKUtxoResult_Sync: {
4823                         LDKCResult_TxOutUtxoLookupErrorZ* sync_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
4824                         *sync_conv = obj->sync;
4825                         *sync_conv = CResult_TxOutUtxoLookupErrorZ_clone(sync_conv);
4826                         return (*env)->NewObject(env, LDKUtxoResult_Sync_class, LDKUtxoResult_Sync_meth, tag_ptr(sync_conv, true));
4827                 }
4828                 case LDKUtxoResult_Async: {
4829                         LDKUtxoFuture async_var = obj->async;
4830                         int64_t async_ref = 0;
4831                         CHECK_INNER_FIELD_ACCESS_OR_NULL(async_var);
4832                         async_ref = tag_ptr(async_var.inner, false);
4833                         return (*env)->NewObject(env, LDKUtxoResult_Async_class, LDKUtxoResult_Async_meth, async_ref);
4834                 }
4835                 default: abort();
4836         }
4837 }
4838 typedef struct LDKUtxoLookup_JCalls {
4839         atomic_size_t refcnt;
4840         JavaVM *vm;
4841         jweak o;
4842         jmethodID get_utxo_meth;
4843 } LDKUtxoLookup_JCalls;
4844 static void LDKUtxoLookup_JCalls_free(void* this_arg) {
4845         LDKUtxoLookup_JCalls *j_calls = (LDKUtxoLookup_JCalls*) this_arg;
4846         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4847                 JNIEnv *env;
4848                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4849                 if (get_jenv_res == JNI_EDETACHED) {
4850                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4851                 } else {
4852                         DO_ASSERT(get_jenv_res == JNI_OK);
4853                 }
4854                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4855                 if (get_jenv_res == JNI_EDETACHED) {
4856                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4857                 }
4858                 FREE(j_calls);
4859         }
4860 }
4861 LDKUtxoResult get_utxo_LDKUtxoLookup_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4862         LDKUtxoLookup_JCalls *j_calls = (LDKUtxoLookup_JCalls*) this_arg;
4863         JNIEnv *env;
4864         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4865         if (get_jenv_res == JNI_EDETACHED) {
4866                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4867         } else {
4868                 DO_ASSERT(get_jenv_res == JNI_OK);
4869         }
4870         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
4871         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
4872         int64_t short_channel_id_conv = short_channel_id;
4873         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4874         CHECK(obj != NULL);
4875         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
4876         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4877                 (*env)->ExceptionDescribe(env);
4878                 (*env)->FatalError(env, "A call to get_utxo in LDKUtxoLookup from rust threw an exception.");
4879         }
4880         void* ret_ptr = untag_ptr(ret);
4881         CHECK_ACCESS(ret_ptr);
4882         LDKUtxoResult ret_conv = *(LDKUtxoResult*)(ret_ptr);
4883         FREE(untag_ptr(ret));
4884         if (get_jenv_res == JNI_EDETACHED) {
4885                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4886         }
4887         return ret_conv;
4888 }
4889 static void LDKUtxoLookup_JCalls_cloned(LDKUtxoLookup* new_obj) {
4890         LDKUtxoLookup_JCalls *j_calls = (LDKUtxoLookup_JCalls*) new_obj->this_arg;
4891         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4892 }
4893 static inline LDKUtxoLookup LDKUtxoLookup_init (JNIEnv *env, jclass clz, jobject o) {
4894         jclass c = (*env)->GetObjectClass(env, o);
4895         CHECK(c != NULL);
4896         LDKUtxoLookup_JCalls *calls = MALLOC(sizeof(LDKUtxoLookup_JCalls), "LDKUtxoLookup_JCalls");
4897         atomic_init(&calls->refcnt, 1);
4898         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4899         calls->o = (*env)->NewWeakGlobalRef(env, o);
4900         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
4901         CHECK(calls->get_utxo_meth != NULL);
4902
4903         LDKUtxoLookup ret = {
4904                 .this_arg = (void*) calls,
4905                 .get_utxo = get_utxo_LDKUtxoLookup_jcall,
4906                 .free = LDKUtxoLookup_JCalls_free,
4907         };
4908         return ret;
4909 }
4910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKUtxoLookup_1new(JNIEnv *env, jclass clz, jobject o) {
4911         LDKUtxoLookup *res_ptr = MALLOC(sizeof(LDKUtxoLookup), "LDKUtxoLookup");
4912         *res_ptr = LDKUtxoLookup_init(env, clz, o);
4913         return tag_ptr(res_ptr, true);
4914 }
4915 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) {
4916         void* this_arg_ptr = untag_ptr(this_arg);
4917         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4918         LDKUtxoLookup* this_arg_conv = (LDKUtxoLookup*)this_arg_ptr;
4919         uint8_t genesis_hash_arr[32];
4920         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
4921         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
4922         uint8_t (*genesis_hash_ref)[32] = &genesis_hash_arr;
4923         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
4924         *ret_copy = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4925         int64_t ret_ref = tag_ptr(ret_copy, true);
4926         return ret_ref;
4927 }
4928
4929 static jclass LDKCOption_UtxoLookupZ_Some_class = NULL;
4930 static jmethodID LDKCOption_UtxoLookupZ_Some_meth = NULL;
4931 static jclass LDKCOption_UtxoLookupZ_None_class = NULL;
4932 static jmethodID LDKCOption_UtxoLookupZ_None_meth = NULL;
4933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1UtxoLookupZ_init (JNIEnv *env, jclass clz) {
4934         LDKCOption_UtxoLookupZ_Some_class =
4935                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_UtxoLookupZ$Some"));
4936         CHECK(LDKCOption_UtxoLookupZ_Some_class != NULL);
4937         LDKCOption_UtxoLookupZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_UtxoLookupZ_Some_class, "<init>", "(J)V");
4938         CHECK(LDKCOption_UtxoLookupZ_Some_meth != NULL);
4939         LDKCOption_UtxoLookupZ_None_class =
4940                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_UtxoLookupZ$None"));
4941         CHECK(LDKCOption_UtxoLookupZ_None_class != NULL);
4942         LDKCOption_UtxoLookupZ_None_meth = (*env)->GetMethodID(env, LDKCOption_UtxoLookupZ_None_class, "<init>", "()V");
4943         CHECK(LDKCOption_UtxoLookupZ_None_meth != NULL);
4944 }
4945 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1UtxoLookupZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4946         LDKCOption_UtxoLookupZ *obj = (LDKCOption_UtxoLookupZ*)untag_ptr(ptr);
4947         switch(obj->tag) {
4948                 case LDKCOption_UtxoLookupZ_Some: {
4949                         LDKUtxoLookup* some_ret = MALLOC(sizeof(LDKUtxoLookup), "LDKUtxoLookup");
4950                         *some_ret = obj->some;
4951                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
4952                         if ((*some_ret).free == LDKUtxoLookup_JCalls_free) {
4953                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4954                                 LDKUtxoLookup_JCalls_cloned(&(*some_ret));
4955                         }
4956                         return (*env)->NewObject(env, LDKCOption_UtxoLookupZ_Some_class, LDKCOption_UtxoLookupZ_Some_meth, tag_ptr(some_ret, true));
4957                 }
4958                 case LDKCOption_UtxoLookupZ_None: {
4959                         return (*env)->NewObject(env, LDKCOption_UtxoLookupZ_None_class, LDKCOption_UtxoLookupZ_None_meth);
4960                 }
4961                 default: abort();
4962         }
4963 }
4964 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4965 CHECK(owner->result_ok);
4966         return *owner->contents.result;
4967 }
4968 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4969         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4970         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
4971         return ret_conv;
4972 }
4973
4974 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4975         LDKLightningError ret = *owner->contents.err;
4976         ret.is_owned = false;
4977         return ret;
4978 }
4979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4980         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4981         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
4982         int64_t ret_ref = 0;
4983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4984         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4985         return ret_ref;
4986 }
4987
4988 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4989         LDKChannelAnnouncement ret = owner->a;
4990         ret.is_owned = false;
4991         return ret;
4992 }
4993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4994         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4995         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
4996         int64_t ret_ref = 0;
4997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4998         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4999         return ret_ref;
5000 }
5001
5002 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5003         LDKChannelUpdate ret = owner->b;
5004         ret.is_owned = false;
5005         return ret;
5006 }
5007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5008         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
5009         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
5010         int64_t ret_ref = 0;
5011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5012         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5013         return ret_ref;
5014 }
5015
5016 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5017         LDKChannelUpdate ret = owner->c;
5018         ret.is_owned = false;
5019         return ret;
5020 }
5021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
5022         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
5023         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
5024         int64_t ret_ref = 0;
5025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5026         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5027         return ret_ref;
5028 }
5029
5030 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class = NULL;
5031 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = NULL;
5032 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class = NULL;
5033 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = NULL;
5034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_init (JNIEnv *env, jclass clz) {
5035         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class =
5036                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$Some"));
5037         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class != NULL);
5038         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, "<init>", "(J)V");
5039         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth != NULL);
5040         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class =
5041                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$None"));
5042         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class != NULL);
5043         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, "<init>", "()V");
5044         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth != NULL);
5045 }
5046 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5047         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *obj = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(ptr);
5048         switch(obj->tag) {
5049                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some: {
5050                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* some_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5051                         *some_conv = obj->some;
5052                         *some_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(some_conv);
5053                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth, tag_ptr(some_conv, true));
5054                 }
5055                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None: {
5056                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth);
5057                 }
5058                 default: abort();
5059         }
5060 }
5061 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5062 CHECK(owner->result_ok);
5063         return *owner->contents.result;
5064 }
5065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5066         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
5067         CResult_NoneLightningErrorZ_get_ok(owner_conv);
5068 }
5069
5070 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5071         LDKLightningError ret = *owner->contents.err;
5072         ret.is_owned = false;
5073         return ret;
5074 }
5075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5076         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
5077         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
5078         int64_t ret_ref = 0;
5079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5080         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5081         return ret_ref;
5082 }
5083
5084 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
5085         LDKChannelUpdateInfo ret = *owner->contents.result;
5086         ret.is_owned = false;
5087         return ret;
5088 }
5089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5090         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
5091         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
5092         int64_t ret_ref = 0;
5093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5094         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5095         return ret_ref;
5096 }
5097
5098 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
5099 CHECK(!owner->result_ok);
5100         return DecodeError_clone(&*owner->contents.err);
5101 }
5102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5103         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
5104         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5105         *ret_copy = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
5106         int64_t ret_ref = tag_ptr(ret_copy, true);
5107         return ret_ref;
5108 }
5109
5110 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
5111         LDKChannelInfo ret = *owner->contents.result;
5112         ret.is_owned = false;
5113         return ret;
5114 }
5115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5116         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
5117         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
5118         int64_t ret_ref = 0;
5119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5120         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5121         return ret_ref;
5122 }
5123
5124 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
5125 CHECK(!owner->result_ok);
5126         return DecodeError_clone(&*owner->contents.err);
5127 }
5128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5129         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
5130         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5131         *ret_copy = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
5132         int64_t ret_ref = tag_ptr(ret_copy, true);
5133         return ret_ref;
5134 }
5135
5136 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
5137         LDKRoutingFees ret = *owner->contents.result;
5138         ret.is_owned = false;
5139         return ret;
5140 }
5141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5142         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
5143         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
5144         int64_t ret_ref = 0;
5145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5146         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5147         return ret_ref;
5148 }
5149
5150 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
5151 CHECK(!owner->result_ok);
5152         return DecodeError_clone(&*owner->contents.err);
5153 }
5154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5155         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
5156         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5157         *ret_copy = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
5158         int64_t ret_ref = tag_ptr(ret_copy, true);
5159         return ret_ref;
5160 }
5161
5162 static jclass LDKNetAddress_IPv4_class = NULL;
5163 static jmethodID LDKNetAddress_IPv4_meth = NULL;
5164 static jclass LDKNetAddress_IPv6_class = NULL;
5165 static jmethodID LDKNetAddress_IPv6_meth = NULL;
5166 static jclass LDKNetAddress_OnionV2_class = NULL;
5167 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
5168 static jclass LDKNetAddress_OnionV3_class = NULL;
5169 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
5170 static jclass LDKNetAddress_Hostname_class = NULL;
5171 static jmethodID LDKNetAddress_Hostname_meth = NULL;
5172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
5173         LDKNetAddress_IPv4_class =
5174                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
5175         CHECK(LDKNetAddress_IPv4_class != NULL);
5176         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
5177         CHECK(LDKNetAddress_IPv4_meth != NULL);
5178         LDKNetAddress_IPv6_class =
5179                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
5180         CHECK(LDKNetAddress_IPv6_class != NULL);
5181         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
5182         CHECK(LDKNetAddress_IPv6_meth != NULL);
5183         LDKNetAddress_OnionV2_class =
5184                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
5185         CHECK(LDKNetAddress_OnionV2_class != NULL);
5186         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
5187         CHECK(LDKNetAddress_OnionV2_meth != NULL);
5188         LDKNetAddress_OnionV3_class =
5189                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
5190         CHECK(LDKNetAddress_OnionV3_class != NULL);
5191         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
5192         CHECK(LDKNetAddress_OnionV3_meth != NULL);
5193         LDKNetAddress_Hostname_class =
5194                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$Hostname"));
5195         CHECK(LDKNetAddress_Hostname_class != NULL);
5196         LDKNetAddress_Hostname_meth = (*env)->GetMethodID(env, LDKNetAddress_Hostname_class, "<init>", "(JS)V");
5197         CHECK(LDKNetAddress_Hostname_meth != NULL);
5198 }
5199 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5200         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
5201         switch(obj->tag) {
5202                 case LDKNetAddress_IPv4: {
5203                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
5204                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
5205                         int16_t port_conv = obj->i_pv4.port;
5206                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
5207                 }
5208                 case LDKNetAddress_IPv6: {
5209                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
5210                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
5211                         int16_t port_conv = obj->i_pv6.port;
5212                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
5213                 }
5214                 case LDKNetAddress_OnionV2: {
5215                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
5216                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
5217                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
5218                 }
5219                 case LDKNetAddress_OnionV3: {
5220                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
5221                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
5222                         int16_t checksum_conv = obj->onion_v3.checksum;
5223                         int8_t version_conv = obj->onion_v3.version;
5224                         int16_t port_conv = obj->onion_v3.port;
5225                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
5226                 }
5227                 case LDKNetAddress_Hostname: {
5228                         LDKHostname hostname_var = obj->hostname.hostname;
5229                         int64_t hostname_ref = 0;
5230                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
5231                         hostname_ref = tag_ptr(hostname_var.inner, false);
5232                         int16_t port_conv = obj->hostname.port;
5233                         return (*env)->NewObject(env, LDKNetAddress_Hostname_class, LDKNetAddress_Hostname_meth, hostname_ref, port_conv);
5234                 }
5235                 default: abort();
5236         }
5237 }
5238 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
5239         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
5240         for (size_t i = 0; i < ret.datalen; i++) {
5241                 ret.data[i] = NetAddress_clone(&orig->data[i]);
5242         }
5243         return ret;
5244 }
5245 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
5246         LDKNodeAnnouncementInfo ret = *owner->contents.result;
5247         ret.is_owned = false;
5248         return ret;
5249 }
5250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5251         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
5252         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
5253         int64_t ret_ref = 0;
5254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5255         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5256         return ret_ref;
5257 }
5258
5259 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
5260 CHECK(!owner->result_ok);
5261         return DecodeError_clone(&*owner->contents.err);
5262 }
5263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5264         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
5265         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5266         *ret_copy = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
5267         int64_t ret_ref = tag_ptr(ret_copy, true);
5268         return ret_ref;
5269 }
5270
5271 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
5272         LDKNodeAlias ret = *owner->contents.result;
5273         ret.is_owned = false;
5274         return ret;
5275 }
5276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5277         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
5278         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
5279         int64_t ret_ref = 0;
5280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5281         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5282         return ret_ref;
5283 }
5284
5285 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
5286 CHECK(!owner->result_ok);
5287         return DecodeError_clone(&*owner->contents.err);
5288 }
5289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5290         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
5291         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5292         *ret_copy = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
5293         int64_t ret_ref = tag_ptr(ret_copy, true);
5294         return ret_ref;
5295 }
5296
5297 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
5298         LDKNodeInfo ret = *owner->contents.result;
5299         ret.is_owned = false;
5300         return ret;
5301 }
5302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5303         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
5304         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
5305         int64_t ret_ref = 0;
5306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5307         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5308         return ret_ref;
5309 }
5310
5311 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
5312 CHECK(!owner->result_ok);
5313         return DecodeError_clone(&*owner->contents.err);
5314 }
5315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5316         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
5317         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5318         *ret_copy = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
5319         int64_t ret_ref = tag_ptr(ret_copy, true);
5320         return ret_ref;
5321 }
5322
5323 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
5324         LDKNetworkGraph ret = *owner->contents.result;
5325         ret.is_owned = false;
5326         return ret;
5327 }
5328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5329         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
5330         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
5331         int64_t ret_ref = 0;
5332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5333         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5334         return ret_ref;
5335 }
5336
5337 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
5338 CHECK(!owner->result_ok);
5339         return DecodeError_clone(&*owner->contents.err);
5340 }
5341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5342         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
5343         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5344         *ret_copy = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
5345         int64_t ret_ref = tag_ptr(ret_copy, true);
5346         return ret_ref;
5347 }
5348
5349 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
5350 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
5351 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
5352 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
5353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
5354         LDKCOption_CVec_NetAddressZZ_Some_class =
5355                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
5356         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
5357         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
5358         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
5359         LDKCOption_CVec_NetAddressZZ_None_class =
5360                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
5361         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
5362         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
5363         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
5364 }
5365 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5366         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(ptr);
5367         switch(obj->tag) {
5368                 case LDKCOption_CVec_NetAddressZZ_Some: {
5369                         LDKCVec_NetAddressZ some_var = obj->some;
5370                         int64_tArray some_arr = NULL;
5371                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
5372                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
5373                         for (size_t m = 0; m < some_var.datalen; m++) {
5374                                 int64_t some_conv_12_ref = tag_ptr(&some_var.data[m], false);
5375                                 some_arr_ptr[m] = some_conv_12_ref;
5376                         }
5377                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
5378                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
5379                 }
5380                 case LDKCOption_CVec_NetAddressZZ_None: {
5381                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
5382                 }
5383                 default: abort();
5384         }
5385 }
5386 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5387         LDKDelayedPaymentOutputDescriptor ret = *owner->contents.result;
5388         ret.is_owned = false;
5389         return ret;
5390 }
5391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5392         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5393         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5394         int64_t ret_ref = 0;
5395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5396         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5397         return ret_ref;
5398 }
5399
5400 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5401 CHECK(!owner->result_ok);
5402         return DecodeError_clone(&*owner->contents.err);
5403 }
5404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5405         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5406         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5407         *ret_copy = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5408         int64_t ret_ref = tag_ptr(ret_copy, true);
5409         return ret_ref;
5410 }
5411
5412 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5413         LDKStaticPaymentOutputDescriptor ret = *owner->contents.result;
5414         ret.is_owned = false;
5415         return ret;
5416 }
5417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5418         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5419         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5420         int64_t ret_ref = 0;
5421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5422         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5423         return ret_ref;
5424 }
5425
5426 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5427 CHECK(!owner->result_ok);
5428         return DecodeError_clone(&*owner->contents.err);
5429 }
5430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5431         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5432         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5433         *ret_copy = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5434         int64_t ret_ref = tag_ptr(ret_copy, true);
5435         return ret_ref;
5436 }
5437
5438 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5439 CHECK(owner->result_ok);
5440         return SpendableOutputDescriptor_clone(&*owner->contents.result);
5441 }
5442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5443         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5444         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
5445         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5446         int64_t ret_ref = tag_ptr(ret_copy, true);
5447         return ret_ref;
5448 }
5449
5450 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5451 CHECK(!owner->result_ok);
5452         return DecodeError_clone(&*owner->contents.err);
5453 }
5454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5455         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5456         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5457         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5458         int64_t ret_ref = tag_ptr(ret_copy, true);
5459         return ret_ref;
5460 }
5461
5462 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
5463         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
5464         for (size_t i = 0; i < ret.datalen; i++) {
5465                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
5466         }
5467         return ret;
5468 }
5469 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
5470         return owner->a;
5471 }
5472 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5473         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
5474         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5475         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
5476         return ret_arr;
5477 }
5478
5479 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
5480         return owner->b;
5481 }
5482 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5483         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
5484         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
5485         jobjectArray ret_arr = NULL;
5486         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
5487         ;
5488         for (size_t i = 0; i < ret_var.datalen; i++) {
5489                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
5490                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
5491                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
5492         }
5493         
5494         return ret_arr;
5495 }
5496
5497 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
5498 CHECK(owner->result_ok);
5499         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
5500 }
5501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5502         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
5503         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
5504         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
5505         return tag_ptr(ret_conv, true);
5506 }
5507
5508 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
5509 CHECK(!owner->result_ok);
5510         return *owner->contents.err;
5511 }
5512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5513         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
5514         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
5515 }
5516
5517 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5518 CHECK(owner->result_ok);
5519         return *owner->contents.result;
5520 }
5521 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5522         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5523         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5524         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
5525         return ret_arr;
5526 }
5527
5528 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5529 CHECK(!owner->result_ok);
5530         return *owner->contents.err;
5531 }
5532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5533         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5534         CResult_SignatureNoneZ_get_err(owner_conv);
5535 }
5536
5537 static inline struct LDKPublicKey CResult_PublicKeyNoneZ_get_ok(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
5538 CHECK(owner->result_ok);
5539         return *owner->contents.result;
5540 }
5541 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5542         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
5543         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5544         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyNoneZ_get_ok(owner_conv).compressed_form);
5545         return ret_arr;
5546 }
5547
5548 static inline void CResult_PublicKeyNoneZ_get_err(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
5549 CHECK(!owner->result_ok);
5550         return *owner->contents.err;
5551 }
5552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5553         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
5554         CResult_PublicKeyNoneZ_get_err(owner_conv);
5555 }
5556
5557 static jclass LDKCOption_ScalarZ_Some_class = NULL;
5558 static jmethodID LDKCOption_ScalarZ_Some_meth = NULL;
5559 static jclass LDKCOption_ScalarZ_None_class = NULL;
5560 static jmethodID LDKCOption_ScalarZ_None_meth = NULL;
5561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ScalarZ_init (JNIEnv *env, jclass clz) {
5562         LDKCOption_ScalarZ_Some_class =
5563                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$Some"));
5564         CHECK(LDKCOption_ScalarZ_Some_class != NULL);
5565         LDKCOption_ScalarZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_Some_class, "<init>", "(J)V");
5566         CHECK(LDKCOption_ScalarZ_Some_meth != NULL);
5567         LDKCOption_ScalarZ_None_class =
5568                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$None"));
5569         CHECK(LDKCOption_ScalarZ_None_class != NULL);
5570         LDKCOption_ScalarZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_None_class, "<init>", "()V");
5571         CHECK(LDKCOption_ScalarZ_None_meth != NULL);
5572 }
5573 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ScalarZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5574         LDKCOption_ScalarZ *obj = (LDKCOption_ScalarZ*)untag_ptr(ptr);
5575         switch(obj->tag) {
5576                 case LDKCOption_ScalarZ_Some: {
5577                         LDKBigEndianScalar* some_ref = &obj->some;
5578                         return (*env)->NewObject(env, LDKCOption_ScalarZ_Some_class, LDKCOption_ScalarZ_Some_meth, tag_ptr(some_ref, false));
5579                 }
5580                 case LDKCOption_ScalarZ_None: {
5581                         return (*env)->NewObject(env, LDKCOption_ScalarZ_None_class, LDKCOption_ScalarZ_None_meth);
5582                 }
5583                 default: abort();
5584         }
5585 }
5586 static inline struct LDKThirtyTwoBytes CResult_SharedSecretNoneZ_get_ok(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5587 CHECK(owner->result_ok);
5588         return ThirtyTwoBytes_clone(&*owner->contents.result);
5589 }
5590 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5591         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5592         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5593         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SharedSecretNoneZ_get_ok(owner_conv).data);
5594         return ret_arr;
5595 }
5596
5597 static inline void CResult_SharedSecretNoneZ_get_err(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5598 CHECK(!owner->result_ok);
5599         return *owner->contents.err;
5600 }
5601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5602         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5603         CResult_SharedSecretNoneZ_get_err(owner_conv);
5604 }
5605
5606 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5607 CHECK(owner->result_ok);
5608         return *owner->contents.result;
5609 }
5610 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5611         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
5612         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
5613         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
5614         return ret_arr;
5615 }
5616
5617 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5618 CHECK(!owner->result_ok);
5619         return *owner->contents.err;
5620 }
5621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5622         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
5623         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
5624 }
5625
5626 typedef struct LDKChannelSigner_JCalls {
5627         atomic_size_t refcnt;
5628         JavaVM *vm;
5629         jweak o;
5630         jmethodID get_per_commitment_point_meth;
5631         jmethodID release_commitment_secret_meth;
5632         jmethodID validate_holder_commitment_meth;
5633         jmethodID channel_keys_id_meth;
5634         jmethodID provide_channel_parameters_meth;
5635 } LDKChannelSigner_JCalls;
5636 static void LDKChannelSigner_JCalls_free(void* this_arg) {
5637         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5638         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5639                 JNIEnv *env;
5640                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5641                 if (get_jenv_res == JNI_EDETACHED) {
5642                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5643                 } else {
5644                         DO_ASSERT(get_jenv_res == JNI_OK);
5645                 }
5646                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5647                 if (get_jenv_res == JNI_EDETACHED) {
5648                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5649                 }
5650                 FREE(j_calls);
5651         }
5652 }
5653 LDKPublicKey get_per_commitment_point_LDKChannelSigner_jcall(const void* this_arg, uint64_t idx) {
5654         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5655         JNIEnv *env;
5656         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5657         if (get_jenv_res == JNI_EDETACHED) {
5658                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5659         } else {
5660                 DO_ASSERT(get_jenv_res == JNI_OK);
5661         }
5662         int64_t idx_conv = idx;
5663         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5664         CHECK(obj != NULL);
5665         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
5666         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5667                 (*env)->ExceptionDescribe(env);
5668                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKChannelSigner from rust threw an exception.");
5669         }
5670         LDKPublicKey ret_ref;
5671         CHECK((*env)->GetArrayLength(env, ret) == 33);
5672         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
5673         if (get_jenv_res == JNI_EDETACHED) {
5674                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5675         }
5676         return ret_ref;
5677 }
5678 LDKThirtyTwoBytes release_commitment_secret_LDKChannelSigner_jcall(const void* this_arg, uint64_t idx) {
5679         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5680         JNIEnv *env;
5681         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5682         if (get_jenv_res == JNI_EDETACHED) {
5683                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5684         } else {
5685                 DO_ASSERT(get_jenv_res == JNI_OK);
5686         }
5687         int64_t idx_conv = idx;
5688         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5689         CHECK(obj != NULL);
5690         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
5691         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5692                 (*env)->ExceptionDescribe(env);
5693                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKChannelSigner from rust threw an exception.");
5694         }
5695         LDKThirtyTwoBytes ret_ref;
5696         CHECK((*env)->GetArrayLength(env, ret) == 32);
5697         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5698         if (get_jenv_res == JNI_EDETACHED) {
5699                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5700         }
5701         return ret_ref;
5702 }
5703 LDKCResult_NoneNoneZ validate_holder_commitment_LDKChannelSigner_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
5704         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5705         JNIEnv *env;
5706         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5707         if (get_jenv_res == JNI_EDETACHED) {
5708                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5709         } else {
5710                 DO_ASSERT(get_jenv_res == JNI_OK);
5711         }
5712         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
5713         int64_t holder_tx_ref = 0;
5714         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
5715         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
5716         holder_tx_ref = tag_ptr(holder_tx_var.inner, holder_tx_var.is_owned);
5717         LDKCVec_PaymentPreimageZ preimages_var = preimages;
5718         jobjectArray preimages_arr = NULL;
5719         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
5720         ;
5721         for (size_t i = 0; i < preimages_var.datalen; i++) {
5722                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
5723                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
5724                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
5725         }
5726         
5727         FREE(preimages_var.data);
5728         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5729         CHECK(obj != NULL);
5730         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
5731         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5732                 (*env)->ExceptionDescribe(env);
5733                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKChannelSigner from rust threw an exception.");
5734         }
5735         void* ret_ptr = untag_ptr(ret);
5736         CHECK_ACCESS(ret_ptr);
5737         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
5738         FREE(untag_ptr(ret));
5739         if (get_jenv_res == JNI_EDETACHED) {
5740                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5741         }
5742         return ret_conv;
5743 }
5744 LDKThirtyTwoBytes channel_keys_id_LDKChannelSigner_jcall(const void* this_arg) {
5745         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5746         JNIEnv *env;
5747         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5748         if (get_jenv_res == JNI_EDETACHED) {
5749                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5750         } else {
5751                 DO_ASSERT(get_jenv_res == JNI_OK);
5752         }
5753         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5754         CHECK(obj != NULL);
5755         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
5756         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5757                 (*env)->ExceptionDescribe(env);
5758                 (*env)->FatalError(env, "A call to channel_keys_id in LDKChannelSigner from rust threw an exception.");
5759         }
5760         LDKThirtyTwoBytes ret_ref;
5761         CHECK((*env)->GetArrayLength(env, ret) == 32);
5762         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5763         if (get_jenv_res == JNI_EDETACHED) {
5764                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5765         }
5766         return ret_ref;
5767 }
5768 void provide_channel_parameters_LDKChannelSigner_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
5769         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5770         JNIEnv *env;
5771         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5772         if (get_jenv_res == JNI_EDETACHED) {
5773                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5774         } else {
5775                 DO_ASSERT(get_jenv_res == JNI_OK);
5776         }
5777         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
5778         int64_t channel_parameters_ref = 0;
5779         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
5780         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
5781         channel_parameters_ref = tag_ptr(channel_parameters_var.inner, channel_parameters_var.is_owned);
5782         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5783         CHECK(obj != NULL);
5784         (*env)->CallVoidMethod(env, obj, j_calls->provide_channel_parameters_meth, channel_parameters_ref);
5785         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5786                 (*env)->ExceptionDescribe(env);
5787                 (*env)->FatalError(env, "A call to provide_channel_parameters in LDKChannelSigner from rust threw an exception.");
5788         }
5789         if (get_jenv_res == JNI_EDETACHED) {
5790                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5791         }
5792 }
5793 static inline LDKChannelSigner LDKChannelSigner_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5794         jclass c = (*env)->GetObjectClass(env, o);
5795         CHECK(c != NULL);
5796         LDKChannelSigner_JCalls *calls = MALLOC(sizeof(LDKChannelSigner_JCalls), "LDKChannelSigner_JCalls");
5797         atomic_init(&calls->refcnt, 1);
5798         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5799         calls->o = (*env)->NewWeakGlobalRef(env, o);
5800         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
5801         CHECK(calls->get_per_commitment_point_meth != NULL);
5802         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
5803         CHECK(calls->release_commitment_secret_meth != NULL);
5804         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
5805         CHECK(calls->validate_holder_commitment_meth != NULL);
5806         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
5807         CHECK(calls->channel_keys_id_meth != NULL);
5808         calls->provide_channel_parameters_meth = (*env)->GetMethodID(env, c, "provide_channel_parameters", "(J)V");
5809         CHECK(calls->provide_channel_parameters_meth != NULL);
5810
5811         LDKChannelPublicKeys pubkeys_conv;
5812         pubkeys_conv.inner = untag_ptr(pubkeys);
5813         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
5814         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5815
5816         LDKChannelSigner ret = {
5817                 .this_arg = (void*) calls,
5818                 .get_per_commitment_point = get_per_commitment_point_LDKChannelSigner_jcall,
5819                 .release_commitment_secret = release_commitment_secret_LDKChannelSigner_jcall,
5820                 .validate_holder_commitment = validate_holder_commitment_LDKChannelSigner_jcall,
5821                 .channel_keys_id = channel_keys_id_LDKChannelSigner_jcall,
5822                 .provide_channel_parameters = provide_channel_parameters_LDKChannelSigner_jcall,
5823                 .free = LDKChannelSigner_JCalls_free,
5824                 .pubkeys = pubkeys_conv,
5825                 .set_pubkeys = NULL,
5826         };
5827         return ret;
5828 }
5829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelSigner_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5830         LDKChannelSigner *res_ptr = MALLOC(sizeof(LDKChannelSigner), "LDKChannelSigner");
5831         *res_ptr = LDKChannelSigner_init(env, clz, o, pubkeys);
5832         return tag_ptr(res_ptr, true);
5833 }
5834 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) {
5835         void* this_arg_ptr = untag_ptr(this_arg);
5836         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5837         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
5838         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5839         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
5840         return ret_arr;
5841 }
5842
5843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
5844         void* this_arg_ptr = untag_ptr(this_arg);
5845         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5846         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
5847         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5848         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
5849         return ret_arr;
5850 }
5851
5852 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) {
5853         void* this_arg_ptr = untag_ptr(this_arg);
5854         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5855         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
5856         LDKHolderCommitmentTransaction holder_tx_conv;
5857         holder_tx_conv.inner = untag_ptr(holder_tx);
5858         holder_tx_conv.is_owned = ptr_is_owned(holder_tx);
5859         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
5860         holder_tx_conv.is_owned = false;
5861         LDKCVec_PaymentPreimageZ preimages_constr;
5862         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5863         if (preimages_constr.datalen > 0)
5864                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5865         else
5866                 preimages_constr.data = NULL;
5867         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5868                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5869                 LDKThirtyTwoBytes preimages_conv_8_ref;
5870                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5871                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5872                 preimages_constr.data[i] = preimages_conv_8_ref;
5873         }
5874         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5875         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
5876         return tag_ptr(ret_conv, true);
5877 }
5878
5879 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5880         void* this_arg_ptr = untag_ptr(this_arg);
5881         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5882         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
5883         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5884         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
5885         return ret_arr;
5886 }
5887
5888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1provide_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
5889         void* this_arg_ptr = untag_ptr(this_arg);
5890         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5891         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
5892         LDKChannelTransactionParameters channel_parameters_conv;
5893         channel_parameters_conv.inner = untag_ptr(channel_parameters);
5894         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
5895         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
5896         channel_parameters_conv.is_owned = false;
5897         (this_arg_conv->provide_channel_parameters)(this_arg_conv->this_arg, &channel_parameters_conv);
5898 }
5899
5900 LDKChannelPublicKeys LDKChannelSigner_set_get_pubkeys(LDKChannelSigner* this_arg) {
5901         if (this_arg->set_pubkeys != NULL)
5902                 this_arg->set_pubkeys(this_arg);
5903         return this_arg->pubkeys;
5904 }
5905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
5906         void* this_arg_ptr = untag_ptr(this_arg);
5907         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5908         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
5909         LDKChannelPublicKeys ret_var = LDKChannelSigner_set_get_pubkeys(this_arg_conv);
5910         int64_t ret_ref = 0;
5911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5912         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5913         return ret_ref;
5914 }
5915
5916 typedef struct LDKEcdsaChannelSigner_JCalls {
5917         atomic_size_t refcnt;
5918         JavaVM *vm;
5919         jweak o;
5920         LDKChannelSigner_JCalls* ChannelSigner;
5921         jmethodID sign_counterparty_commitment_meth;
5922         jmethodID validate_counterparty_revocation_meth;
5923         jmethodID sign_holder_commitment_and_htlcs_meth;
5924         jmethodID sign_justice_revoked_output_meth;
5925         jmethodID sign_justice_revoked_htlc_meth;
5926         jmethodID sign_counterparty_htlc_transaction_meth;
5927         jmethodID sign_closing_transaction_meth;
5928         jmethodID sign_holder_anchor_input_meth;
5929         jmethodID sign_channel_announcement_with_funding_key_meth;
5930 } LDKEcdsaChannelSigner_JCalls;
5931 static void LDKEcdsaChannelSigner_JCalls_free(void* this_arg) {
5932         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
5933         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
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                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5942                 if (get_jenv_res == JNI_EDETACHED) {
5943                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5944                 }
5945                 FREE(j_calls);
5946         }
5947 }
5948 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
5949         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
5950         JNIEnv *env;
5951         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5952         if (get_jenv_res == JNI_EDETACHED) {
5953                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5954         } else {
5955                 DO_ASSERT(get_jenv_res == JNI_OK);
5956         }
5957         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
5958         int64_t commitment_tx_ref = 0;
5959         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
5960         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
5961         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
5962         LDKCVec_PaymentPreimageZ preimages_var = preimages;
5963         jobjectArray preimages_arr = NULL;
5964         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
5965         ;
5966         for (size_t i = 0; i < preimages_var.datalen; i++) {
5967                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
5968                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
5969                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
5970         }
5971         
5972         FREE(preimages_var.data);
5973         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5974         CHECK(obj != NULL);
5975         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
5976         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5977                 (*env)->ExceptionDescribe(env);
5978                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKEcdsaChannelSigner from rust threw an exception.");
5979         }
5980         void* ret_ptr = untag_ptr(ret);
5981         CHECK_ACCESS(ret_ptr);
5982         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
5983         FREE(untag_ptr(ret));
5984         if (get_jenv_res == JNI_EDETACHED) {
5985                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5986         }
5987         return ret_conv;
5988 }
5989 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKEcdsaChannelSigner_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
5990         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
5991         JNIEnv *env;
5992         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5993         if (get_jenv_res == JNI_EDETACHED) {
5994                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5995         } else {
5996                 DO_ASSERT(get_jenv_res == JNI_OK);
5997         }
5998         int64_t idx_conv = idx;
5999         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
6000         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
6001         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6002         CHECK(obj != NULL);
6003         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
6004         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6005                 (*env)->ExceptionDescribe(env);
6006                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKEcdsaChannelSigner from rust threw an exception.");
6007         }
6008         void* ret_ptr = untag_ptr(ret);
6009         CHECK_ACCESS(ret_ptr);
6010         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
6011         FREE(untag_ptr(ret));
6012         if (get_jenv_res == JNI_EDETACHED) {
6013                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6014         }
6015         return ret_conv;
6016 }
6017 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
6018         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6019         JNIEnv *env;
6020         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6021         if (get_jenv_res == JNI_EDETACHED) {
6022                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6023         } else {
6024                 DO_ASSERT(get_jenv_res == JNI_OK);
6025         }
6026         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
6027         int64_t commitment_tx_ref = 0;
6028         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
6029         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
6030         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
6031         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6032         CHECK(obj != NULL);
6033         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
6034         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6035                 (*env)->ExceptionDescribe(env);
6036                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKEcdsaChannelSigner from rust threw an exception.");
6037         }
6038         void* ret_ptr = untag_ptr(ret);
6039         CHECK_ACCESS(ret_ptr);
6040         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
6041         FREE(untag_ptr(ret));
6042         if (get_jenv_res == JNI_EDETACHED) {
6043                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6044         }
6045         return ret_conv;
6046 }
6047 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]) {
6048         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6049         JNIEnv *env;
6050         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6051         if (get_jenv_res == JNI_EDETACHED) {
6052                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6053         } else {
6054                 DO_ASSERT(get_jenv_res == JNI_OK);
6055         }
6056         LDKTransaction justice_tx_var = justice_tx;
6057         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
6058         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
6059         Transaction_free(justice_tx_var);
6060         int64_t input_conv = input;
6061         int64_t amount_conv = amount;
6062         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
6063         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
6064         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6065         CHECK(obj != NULL);
6066         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);
6067         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6068                 (*env)->ExceptionDescribe(env);
6069                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKEcdsaChannelSigner from rust threw an exception.");
6070         }
6071         void* ret_ptr = untag_ptr(ret);
6072         CHECK_ACCESS(ret_ptr);
6073         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6074         FREE(untag_ptr(ret));
6075         if (get_jenv_res == JNI_EDETACHED) {
6076                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6077         }
6078         return ret_conv;
6079 }
6080 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) {
6081         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6082         JNIEnv *env;
6083         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6084         if (get_jenv_res == JNI_EDETACHED) {
6085                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6086         } else {
6087                 DO_ASSERT(get_jenv_res == JNI_OK);
6088         }
6089         LDKTransaction justice_tx_var = justice_tx;
6090         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
6091         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
6092         Transaction_free(justice_tx_var);
6093         int64_t input_conv = input;
6094         int64_t amount_conv = amount;
6095         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
6096         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
6097         LDKHTLCOutputInCommitment htlc_var = *htlc;
6098         int64_t htlc_ref = 0;
6099         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
6100         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
6101         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
6102         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6103         CHECK(obj != NULL);
6104         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);
6105         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6106                 (*env)->ExceptionDescribe(env);
6107                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKEcdsaChannelSigner from rust threw an exception.");
6108         }
6109         void* ret_ptr = untag_ptr(ret);
6110         CHECK_ACCESS(ret_ptr);
6111         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6112         FREE(untag_ptr(ret));
6113         if (get_jenv_res == JNI_EDETACHED) {
6114                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6115         }
6116         return ret_conv;
6117 }
6118 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) {
6119         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6120         JNIEnv *env;
6121         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6122         if (get_jenv_res == JNI_EDETACHED) {
6123                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6124         } else {
6125                 DO_ASSERT(get_jenv_res == JNI_OK);
6126         }
6127         LDKTransaction htlc_tx_var = htlc_tx;
6128         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
6129         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
6130         Transaction_free(htlc_tx_var);
6131         int64_t input_conv = input;
6132         int64_t amount_conv = amount;
6133         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
6134         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
6135         LDKHTLCOutputInCommitment htlc_var = *htlc;
6136         int64_t htlc_ref = 0;
6137         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
6138         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
6139         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
6140         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6141         CHECK(obj != NULL);
6142         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);
6143         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6144                 (*env)->ExceptionDescribe(env);
6145                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKEcdsaChannelSigner from rust threw an exception.");
6146         }
6147         void* ret_ptr = untag_ptr(ret);
6148         CHECK_ACCESS(ret_ptr);
6149         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6150         FREE(untag_ptr(ret));
6151         if (get_jenv_res == JNI_EDETACHED) {
6152                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6153         }
6154         return ret_conv;
6155 }
6156 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
6157         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6158         JNIEnv *env;
6159         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6160         if (get_jenv_res == JNI_EDETACHED) {
6161                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6162         } else {
6163                 DO_ASSERT(get_jenv_res == JNI_OK);
6164         }
6165         LDKClosingTransaction closing_tx_var = *closing_tx;
6166         int64_t closing_tx_ref = 0;
6167         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
6168         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
6169         closing_tx_ref = tag_ptr(closing_tx_var.inner, closing_tx_var.is_owned);
6170         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6171         CHECK(obj != NULL);
6172         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
6173         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6174                 (*env)->ExceptionDescribe(env);
6175                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKEcdsaChannelSigner from rust threw an exception.");
6176         }
6177         void* ret_ptr = untag_ptr(ret);
6178         CHECK_ACCESS(ret_ptr);
6179         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6180         FREE(untag_ptr(ret));
6181         if (get_jenv_res == JNI_EDETACHED) {
6182                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6183         }
6184         return ret_conv;
6185 }
6186 LDKCResult_SignatureNoneZ sign_holder_anchor_input_LDKEcdsaChannelSigner_jcall(const void* this_arg, LDKTransaction anchor_tx, uintptr_t input) {
6187         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6188         JNIEnv *env;
6189         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6190         if (get_jenv_res == JNI_EDETACHED) {
6191                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6192         } else {
6193                 DO_ASSERT(get_jenv_res == JNI_OK);
6194         }
6195         LDKTransaction anchor_tx_var = anchor_tx;
6196         int8_tArray anchor_tx_arr = (*env)->NewByteArray(env, anchor_tx_var.datalen);
6197         (*env)->SetByteArrayRegion(env, anchor_tx_arr, 0, anchor_tx_var.datalen, anchor_tx_var.data);
6198         Transaction_free(anchor_tx_var);
6199         int64_t input_conv = input;
6200         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6201         CHECK(obj != NULL);
6202         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_anchor_input_meth, anchor_tx_arr, input_conv);
6203         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6204                 (*env)->ExceptionDescribe(env);
6205                 (*env)->FatalError(env, "A call to sign_holder_anchor_input in LDKEcdsaChannelSigner from rust threw an exception.");
6206         }
6207         void* ret_ptr = untag_ptr(ret);
6208         CHECK_ACCESS(ret_ptr);
6209         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6210         FREE(untag_ptr(ret));
6211         if (get_jenv_res == JNI_EDETACHED) {
6212                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6213         }
6214         return ret_conv;
6215 }
6216 LDKCResult_SignatureNoneZ sign_channel_announcement_with_funding_key_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
6217         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6218         JNIEnv *env;
6219         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6220         if (get_jenv_res == JNI_EDETACHED) {
6221                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6222         } else {
6223                 DO_ASSERT(get_jenv_res == JNI_OK);
6224         }
6225         LDKUnsignedChannelAnnouncement msg_var = *msg;
6226         int64_t msg_ref = 0;
6227         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
6228         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6229         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
6230         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6231         CHECK(obj != NULL);
6232         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_with_funding_key_meth, msg_ref);
6233         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6234                 (*env)->ExceptionDescribe(env);
6235                 (*env)->FatalError(env, "A call to sign_channel_announcement_with_funding_key in LDKEcdsaChannelSigner from rust threw an exception.");
6236         }
6237         void* ret_ptr = untag_ptr(ret);
6238         CHECK_ACCESS(ret_ptr);
6239         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6240         FREE(untag_ptr(ret));
6241         if (get_jenv_res == JNI_EDETACHED) {
6242                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6243         }
6244         return ret_conv;
6245 }
6246 static void LDKEcdsaChannelSigner_JCalls_cloned(LDKEcdsaChannelSigner* new_obj) {
6247         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) new_obj->this_arg;
6248         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6249         atomic_fetch_add_explicit(&j_calls->ChannelSigner->refcnt, 1, memory_order_release);
6250 }
6251 static inline LDKEcdsaChannelSigner LDKEcdsaChannelSigner_init (JNIEnv *env, jclass clz, jobject o, jobject ChannelSigner, int64_t pubkeys) {
6252         jclass c = (*env)->GetObjectClass(env, o);
6253         CHECK(c != NULL);
6254         LDKEcdsaChannelSigner_JCalls *calls = MALLOC(sizeof(LDKEcdsaChannelSigner_JCalls), "LDKEcdsaChannelSigner_JCalls");
6255         atomic_init(&calls->refcnt, 1);
6256         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6257         calls->o = (*env)->NewWeakGlobalRef(env, o);
6258         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
6259         CHECK(calls->sign_counterparty_commitment_meth != NULL);
6260         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
6261         CHECK(calls->validate_counterparty_revocation_meth != NULL);
6262         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
6263         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
6264         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
6265         CHECK(calls->sign_justice_revoked_output_meth != NULL);
6266         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
6267         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
6268         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
6269         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
6270         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
6271         CHECK(calls->sign_closing_transaction_meth != NULL);
6272         calls->sign_holder_anchor_input_meth = (*env)->GetMethodID(env, c, "sign_holder_anchor_input", "([BJ)J");
6273         CHECK(calls->sign_holder_anchor_input_meth != NULL);
6274         calls->sign_channel_announcement_with_funding_key_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement_with_funding_key", "(J)J");
6275         CHECK(calls->sign_channel_announcement_with_funding_key_meth != NULL);
6276
6277         LDKChannelPublicKeys pubkeys_conv;
6278         pubkeys_conv.inner = untag_ptr(pubkeys);
6279         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
6280         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
6281
6282         LDKEcdsaChannelSigner ret = {
6283                 .this_arg = (void*) calls,
6284                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKEcdsaChannelSigner_jcall,
6285                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKEcdsaChannelSigner_jcall,
6286                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKEcdsaChannelSigner_jcall,
6287                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKEcdsaChannelSigner_jcall,
6288                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKEcdsaChannelSigner_jcall,
6289                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKEcdsaChannelSigner_jcall,
6290                 .sign_closing_transaction = sign_closing_transaction_LDKEcdsaChannelSigner_jcall,
6291                 .sign_holder_anchor_input = sign_holder_anchor_input_LDKEcdsaChannelSigner_jcall,
6292                 .sign_channel_announcement_with_funding_key = sign_channel_announcement_with_funding_key_LDKEcdsaChannelSigner_jcall,
6293                 .free = LDKEcdsaChannelSigner_JCalls_free,
6294                 .ChannelSigner = LDKChannelSigner_init(env, clz, ChannelSigner, pubkeys),
6295         };
6296         calls->ChannelSigner = ret.ChannelSigner.this_arg;
6297         return ret;
6298 }
6299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEcdsaChannelSigner_1new(JNIEnv *env, jclass clz, jobject o, jobject ChannelSigner, int64_t pubkeys) {
6300         LDKEcdsaChannelSigner *res_ptr = MALLOC(sizeof(LDKEcdsaChannelSigner), "LDKEcdsaChannelSigner");
6301         *res_ptr = LDKEcdsaChannelSigner_init(env, clz, o, ChannelSigner, pubkeys);
6302         return tag_ptr(res_ptr, true);
6303 }
6304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEcdsaChannelSigner_1get_1ChannelSigner(JNIEnv *env, jclass clz, int64_t arg) {
6305         LDKEcdsaChannelSigner *inp = (LDKEcdsaChannelSigner *)untag_ptr(arg);
6306         return tag_ptr(&inp->ChannelSigner, false);
6307 }
6308 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) {
6309         void* this_arg_ptr = untag_ptr(this_arg);
6310         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6311         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6312         LDKCommitmentTransaction commitment_tx_conv;
6313         commitment_tx_conv.inner = untag_ptr(commitment_tx);
6314         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
6315         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
6316         commitment_tx_conv.is_owned = false;
6317         LDKCVec_PaymentPreimageZ preimages_constr;
6318         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
6319         if (preimages_constr.datalen > 0)
6320                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
6321         else
6322                 preimages_constr.data = NULL;
6323         for (size_t i = 0; i < preimages_constr.datalen; i++) {
6324                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
6325                 LDKThirtyTwoBytes preimages_conv_8_ref;
6326                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
6327                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
6328                 preimages_constr.data[i] = preimages_conv_8_ref;
6329         }
6330         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
6331         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
6332         return tag_ptr(ret_conv, true);
6333 }
6334
6335 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) {
6336         void* this_arg_ptr = untag_ptr(this_arg);
6337         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6338         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6339         uint8_t secret_arr[32];
6340         CHECK((*env)->GetArrayLength(env, secret) == 32);
6341         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
6342         uint8_t (*secret_ref)[32] = &secret_arr;
6343         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
6344         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
6345         return tag_ptr(ret_conv, true);
6346 }
6347
6348 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) {
6349         void* this_arg_ptr = untag_ptr(this_arg);
6350         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6351         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6352         LDKHolderCommitmentTransaction commitment_tx_conv;
6353         commitment_tx_conv.inner = untag_ptr(commitment_tx);
6354         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
6355         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
6356         commitment_tx_conv.is_owned = false;
6357         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
6358         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
6359         return tag_ptr(ret_conv, true);
6360 }
6361
6362 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) {
6363         void* this_arg_ptr = untag_ptr(this_arg);
6364         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6365         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6366         LDKTransaction justice_tx_ref;
6367         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
6368         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
6369         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
6370         justice_tx_ref.data_is_owned = true;
6371         uint8_t per_commitment_key_arr[32];
6372         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
6373         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
6374         uint8_t (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
6375         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6376         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
6377         return tag_ptr(ret_conv, true);
6378 }
6379
6380 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) {
6381         void* this_arg_ptr = untag_ptr(this_arg);
6382         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6383         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6384         LDKTransaction justice_tx_ref;
6385         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
6386         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
6387         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
6388         justice_tx_ref.data_is_owned = true;
6389         uint8_t per_commitment_key_arr[32];
6390         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
6391         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
6392         uint8_t (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
6393         LDKHTLCOutputInCommitment htlc_conv;
6394         htlc_conv.inner = untag_ptr(htlc);
6395         htlc_conv.is_owned = ptr_is_owned(htlc);
6396         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
6397         htlc_conv.is_owned = false;
6398         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6399         *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);
6400         return tag_ptr(ret_conv, true);
6401 }
6402
6403 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) {
6404         void* this_arg_ptr = untag_ptr(this_arg);
6405         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6406         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6407         LDKTransaction htlc_tx_ref;
6408         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
6409         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
6410         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
6411         htlc_tx_ref.data_is_owned = true;
6412         LDKPublicKey per_commitment_point_ref;
6413         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
6414         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
6415         LDKHTLCOutputInCommitment htlc_conv;
6416         htlc_conv.inner = untag_ptr(htlc);
6417         htlc_conv.is_owned = ptr_is_owned(htlc);
6418         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
6419         htlc_conv.is_owned = false;
6420         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6421         *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);
6422         return tag_ptr(ret_conv, true);
6423 }
6424
6425 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) {
6426         void* this_arg_ptr = untag_ptr(this_arg);
6427         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6428         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6429         LDKClosingTransaction closing_tx_conv;
6430         closing_tx_conv.inner = untag_ptr(closing_tx);
6431         closing_tx_conv.is_owned = ptr_is_owned(closing_tx);
6432         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
6433         closing_tx_conv.is_owned = false;
6434         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6435         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
6436         return tag_ptr(ret_conv, true);
6437 }
6438
6439 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) {
6440         void* this_arg_ptr = untag_ptr(this_arg);
6441         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6442         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6443         LDKTransaction anchor_tx_ref;
6444         anchor_tx_ref.datalen = (*env)->GetArrayLength(env, anchor_tx);
6445         anchor_tx_ref.data = MALLOC(anchor_tx_ref.datalen, "LDKTransaction Bytes");
6446         (*env)->GetByteArrayRegion(env, anchor_tx, 0, anchor_tx_ref.datalen, anchor_tx_ref.data);
6447         anchor_tx_ref.data_is_owned = true;
6448         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6449         *ret_conv = (this_arg_conv->sign_holder_anchor_input)(this_arg_conv->this_arg, anchor_tx_ref, input);
6450         return tag_ptr(ret_conv, true);
6451 }
6452
6453 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) {
6454         void* this_arg_ptr = untag_ptr(this_arg);
6455         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6456         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6457         LDKUnsignedChannelAnnouncement msg_conv;
6458         msg_conv.inner = untag_ptr(msg);
6459         msg_conv.is_owned = ptr_is_owned(msg);
6460         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6461         msg_conv.is_owned = false;
6462         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6463         *ret_conv = (this_arg_conv->sign_channel_announcement_with_funding_key)(this_arg_conv->this_arg, &msg_conv);
6464         return tag_ptr(ret_conv, true);
6465 }
6466
6467 typedef struct LDKWriteableEcdsaChannelSigner_JCalls {
6468         atomic_size_t refcnt;
6469         JavaVM *vm;
6470         jweak o;
6471         LDKEcdsaChannelSigner_JCalls* EcdsaChannelSigner;
6472         LDKChannelSigner_JCalls* ChannelSigner;
6473         jmethodID write_meth;
6474 } LDKWriteableEcdsaChannelSigner_JCalls;
6475 static void LDKWriteableEcdsaChannelSigner_JCalls_free(void* this_arg) {
6476         LDKWriteableEcdsaChannelSigner_JCalls *j_calls = (LDKWriteableEcdsaChannelSigner_JCalls*) this_arg;
6477         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6478                 JNIEnv *env;
6479                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6480                 if (get_jenv_res == JNI_EDETACHED) {
6481                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6482                 } else {
6483                         DO_ASSERT(get_jenv_res == JNI_OK);
6484                 }
6485                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6486                 if (get_jenv_res == JNI_EDETACHED) {
6487                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6488                 }
6489                 FREE(j_calls);
6490         }
6491 }
6492 LDKCVec_u8Z write_LDKWriteableEcdsaChannelSigner_jcall(const void* this_arg) {
6493         LDKWriteableEcdsaChannelSigner_JCalls *j_calls = (LDKWriteableEcdsaChannelSigner_JCalls*) this_arg;
6494         JNIEnv *env;
6495         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6496         if (get_jenv_res == JNI_EDETACHED) {
6497                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6498         } else {
6499                 DO_ASSERT(get_jenv_res == JNI_OK);
6500         }
6501         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6502         CHECK(obj != NULL);
6503         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
6504         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6505                 (*env)->ExceptionDescribe(env);
6506                 (*env)->FatalError(env, "A call to write in LDKWriteableEcdsaChannelSigner from rust threw an exception.");
6507         }
6508         LDKCVec_u8Z ret_ref;
6509         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6510         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6511         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6512         if (get_jenv_res == JNI_EDETACHED) {
6513                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6514         }
6515         return ret_ref;
6516 }
6517 static void LDKWriteableEcdsaChannelSigner_JCalls_cloned(LDKWriteableEcdsaChannelSigner* new_obj) {
6518         LDKWriteableEcdsaChannelSigner_JCalls *j_calls = (LDKWriteableEcdsaChannelSigner_JCalls*) new_obj->this_arg;
6519         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6520         atomic_fetch_add_explicit(&j_calls->EcdsaChannelSigner->refcnt, 1, memory_order_release);
6521         atomic_fetch_add_explicit(&j_calls->EcdsaChannelSigner->ChannelSigner->refcnt, 1, memory_order_release);
6522 }
6523 static inline LDKWriteableEcdsaChannelSigner LDKWriteableEcdsaChannelSigner_init (JNIEnv *env, jclass clz, jobject o, jobject EcdsaChannelSigner, jobject ChannelSigner, int64_t pubkeys) {
6524         jclass c = (*env)->GetObjectClass(env, o);
6525         CHECK(c != NULL);
6526         LDKWriteableEcdsaChannelSigner_JCalls *calls = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner_JCalls), "LDKWriteableEcdsaChannelSigner_JCalls");
6527         atomic_init(&calls->refcnt, 1);
6528         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6529         calls->o = (*env)->NewWeakGlobalRef(env, o);
6530         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
6531         CHECK(calls->write_meth != NULL);
6532
6533         LDKChannelPublicKeys pubkeys_conv;
6534         pubkeys_conv.inner = untag_ptr(pubkeys);
6535         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
6536         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
6537
6538         LDKWriteableEcdsaChannelSigner ret = {
6539                 .this_arg = (void*) calls,
6540                 .write = write_LDKWriteableEcdsaChannelSigner_jcall,
6541                 .cloned = LDKWriteableEcdsaChannelSigner_JCalls_cloned,
6542                 .free = LDKWriteableEcdsaChannelSigner_JCalls_free,
6543                 .EcdsaChannelSigner = LDKEcdsaChannelSigner_init(env, clz, EcdsaChannelSigner, ChannelSigner, pubkeys),
6544         };
6545         calls->EcdsaChannelSigner = ret.EcdsaChannelSigner.this_arg;
6546         calls->ChannelSigner = ret.EcdsaChannelSigner.ChannelSigner.this_arg;
6547         return ret;
6548 }
6549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableEcdsaChannelSigner_1new(JNIEnv *env, jclass clz, jobject o, jobject EcdsaChannelSigner, jobject ChannelSigner, int64_t pubkeys) {
6550         LDKWriteableEcdsaChannelSigner *res_ptr = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
6551         *res_ptr = LDKWriteableEcdsaChannelSigner_init(env, clz, o, EcdsaChannelSigner, ChannelSigner, pubkeys);
6552         return tag_ptr(res_ptr, true);
6553 }
6554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableEcdsaChannelSigner_1get_1EcdsaChannelSigner(JNIEnv *env, jclass clz, int64_t arg) {
6555         LDKWriteableEcdsaChannelSigner *inp = (LDKWriteableEcdsaChannelSigner *)untag_ptr(arg);
6556         return tag_ptr(&inp->EcdsaChannelSigner, false);
6557 }
6558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableEcdsaChannelSigner_1get_1ChannelSigner(JNIEnv *env, jclass clz, int64_t arg) {
6559         LDKWriteableEcdsaChannelSigner *inp = (LDKWriteableEcdsaChannelSigner *)untag_ptr(arg);
6560         return tag_ptr(&inp->EcdsaChannelSigner.ChannelSigner, false);
6561 }
6562 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
6563         void* this_arg_ptr = untag_ptr(this_arg);
6564         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6565         LDKWriteableEcdsaChannelSigner* this_arg_conv = (LDKWriteableEcdsaChannelSigner*)this_arg_ptr;
6566         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
6567         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6568         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6569         CVec_u8Z_free(ret_var);
6570         return ret_arr;
6571 }
6572
6573 static inline struct LDKWriteableEcdsaChannelSigner CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_ok(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR owner){
6574 CHECK(owner->result_ok);
6575         return WriteableEcdsaChannelSigner_clone(&*owner->contents.result);
6576 }
6577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6578         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* owner_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(owner);
6579         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
6580         *ret_ret = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_ok(owner_conv);
6581         return tag_ptr(ret_ret, true);
6582 }
6583
6584 static inline struct LDKDecodeError CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_err(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR owner){
6585 CHECK(!owner->result_ok);
6586         return DecodeError_clone(&*owner->contents.err);
6587 }
6588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6589         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* owner_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(owner);
6590         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6591         *ret_copy = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_err(owner_conv);
6592         int64_t ret_ref = tag_ptr(ret_copy, true);
6593         return ret_ref;
6594 }
6595
6596 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
6597         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
6598         for (size_t i = 0; i < ret.datalen; i++) {
6599                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
6600         }
6601         return ret;
6602 }
6603 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6604 CHECK(owner->result_ok);
6605         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
6606 }
6607 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6608         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6609         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
6610         jobjectArray ret_arr = NULL;
6611         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6612         ;
6613         for (size_t i = 0; i < ret_var.datalen; i++) {
6614                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
6615                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
6616                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
6617                 CVec_u8Z_free(ret_conv_8_var);
6618                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6619         }
6620         
6621         FREE(ret_var.data);
6622         return ret_arr;
6623 }
6624
6625 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6626 CHECK(!owner->result_ok);
6627         return *owner->contents.err;
6628 }
6629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6630         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6631         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
6632 }
6633
6634 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6635         LDKInMemorySigner ret = *owner->contents.result;
6636         ret.is_owned = false;
6637         return ret;
6638 }
6639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6640         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6641         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
6642         int64_t ret_ref = 0;
6643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6644         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6645         return ret_ref;
6646 }
6647
6648 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6649 CHECK(!owner->result_ok);
6650         return DecodeError_clone(&*owner->contents.err);
6651 }
6652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6653         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6654         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6655         *ret_copy = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
6656         int64_t ret_ref = tag_ptr(ret_copy, true);
6657         return ret_ref;
6658 }
6659
6660 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
6661         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
6662         for (size_t i = 0; i < ret.datalen; i++) {
6663                 ret.data[i] = TxOut_clone(&orig->data[i]);
6664         }
6665         return ret;
6666 }
6667 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6668 CHECK(owner->result_ok);
6669         return *owner->contents.result;
6670 }
6671 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6672         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6673         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
6674         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6675         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6676         return ret_arr;
6677 }
6678
6679 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6680 CHECK(!owner->result_ok);
6681         return *owner->contents.err;
6682 }
6683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6684         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6685         CResult_TransactionNoneZ_get_err(owner_conv);
6686 }
6687
6688 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6689         return ThirtyTwoBytes_clone(&owner->a);
6690 }
6691 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6692         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6693         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6694         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
6695         return ret_arr;
6696 }
6697
6698 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6699         LDKChannelMonitor ret = owner->b;
6700         ret.is_owned = false;
6701         return ret;
6702 }
6703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6704         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6705         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
6706         int64_t ret_ref = 0;
6707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6708         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6709         return ret_ref;
6710 }
6711
6712 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
6713         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
6714         for (size_t i = 0; i < ret.datalen; i++) {
6715                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
6716         }
6717         return ret;
6718 }
6719 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6720 CHECK(owner->result_ok);
6721         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
6722 }
6723 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6724         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6725         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
6726         int64_tArray ret_arr = NULL;
6727         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6728         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6729         for (size_t j = 0; j < ret_var.datalen; j++) {
6730                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6731                 *ret_conv_35_conv = ret_var.data[j];
6732                 ret_arr_ptr[j] = tag_ptr(ret_conv_35_conv, true);
6733         }
6734         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6735         FREE(ret_var.data);
6736         return ret_arr;
6737 }
6738
6739 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6740 CHECK(!owner->result_ok);
6741         return *owner->contents.err;
6742 }
6743 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6744         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6745         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
6746         return ret_conv;
6747 }
6748
6749 static jclass LDKCOption_u16Z_Some_class = NULL;
6750 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
6751 static jclass LDKCOption_u16Z_None_class = NULL;
6752 static jmethodID LDKCOption_u16Z_None_meth = NULL;
6753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
6754         LDKCOption_u16Z_Some_class =
6755                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
6756         CHECK(LDKCOption_u16Z_Some_class != NULL);
6757         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
6758         CHECK(LDKCOption_u16Z_Some_meth != NULL);
6759         LDKCOption_u16Z_None_class =
6760                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
6761         CHECK(LDKCOption_u16Z_None_class != NULL);
6762         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
6763         CHECK(LDKCOption_u16Z_None_meth != NULL);
6764 }
6765 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6766         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)untag_ptr(ptr);
6767         switch(obj->tag) {
6768                 case LDKCOption_u16Z_Some: {
6769                         int16_t some_conv = obj->some;
6770                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
6771                 }
6772                 case LDKCOption_u16Z_None: {
6773                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
6774                 }
6775                 default: abort();
6776         }
6777 }
6778 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6779 CHECK(owner->result_ok);
6780         return ThirtyTwoBytes_clone(&*owner->contents.result);
6781 }
6782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6783         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6784         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6785         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
6786         return ret_arr;
6787 }
6788
6789 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6790 CHECK(!owner->result_ok);
6791         return APIError_clone(&*owner->contents.err);
6792 }
6793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6794         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6795         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6796         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
6797         int64_t ret_ref = tag_ptr(ret_copy, true);
6798         return ret_ref;
6799 }
6800
6801 static jclass LDKRecentPaymentDetails_Pending_class = NULL;
6802 static jmethodID LDKRecentPaymentDetails_Pending_meth = NULL;
6803 static jclass LDKRecentPaymentDetails_Fulfilled_class = NULL;
6804 static jmethodID LDKRecentPaymentDetails_Fulfilled_meth = NULL;
6805 static jclass LDKRecentPaymentDetails_Abandoned_class = NULL;
6806 static jmethodID LDKRecentPaymentDetails_Abandoned_meth = NULL;
6807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRecentPaymentDetails_init (JNIEnv *env, jclass clz) {
6808         LDKRecentPaymentDetails_Pending_class =
6809                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRecentPaymentDetails$Pending"));
6810         CHECK(LDKRecentPaymentDetails_Pending_class != NULL);
6811         LDKRecentPaymentDetails_Pending_meth = (*env)->GetMethodID(env, LDKRecentPaymentDetails_Pending_class, "<init>", "([BJ)V");
6812         CHECK(LDKRecentPaymentDetails_Pending_meth != NULL);
6813         LDKRecentPaymentDetails_Fulfilled_class =
6814                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRecentPaymentDetails$Fulfilled"));
6815         CHECK(LDKRecentPaymentDetails_Fulfilled_class != NULL);
6816         LDKRecentPaymentDetails_Fulfilled_meth = (*env)->GetMethodID(env, LDKRecentPaymentDetails_Fulfilled_class, "<init>", "([B)V");
6817         CHECK(LDKRecentPaymentDetails_Fulfilled_meth != NULL);
6818         LDKRecentPaymentDetails_Abandoned_class =
6819                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRecentPaymentDetails$Abandoned"));
6820         CHECK(LDKRecentPaymentDetails_Abandoned_class != NULL);
6821         LDKRecentPaymentDetails_Abandoned_meth = (*env)->GetMethodID(env, LDKRecentPaymentDetails_Abandoned_class, "<init>", "([B)V");
6822         CHECK(LDKRecentPaymentDetails_Abandoned_meth != NULL);
6823 }
6824 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRecentPaymentDetails_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6825         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
6826         switch(obj->tag) {
6827                 case LDKRecentPaymentDetails_Pending: {
6828                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
6829                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->pending.payment_hash.data);
6830                         int64_t total_msat_conv = obj->pending.total_msat;
6831                         return (*env)->NewObject(env, LDKRecentPaymentDetails_Pending_class, LDKRecentPaymentDetails_Pending_meth, payment_hash_arr, total_msat_conv);
6832                 }
6833                 case LDKRecentPaymentDetails_Fulfilled: {
6834                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
6835                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->fulfilled.payment_hash.data);
6836                         return (*env)->NewObject(env, LDKRecentPaymentDetails_Fulfilled_class, LDKRecentPaymentDetails_Fulfilled_meth, payment_hash_arr);
6837                 }
6838                 case LDKRecentPaymentDetails_Abandoned: {
6839                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
6840                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->abandoned.payment_hash.data);
6841                         return (*env)->NewObject(env, LDKRecentPaymentDetails_Abandoned_class, LDKRecentPaymentDetails_Abandoned_meth, payment_hash_arr);
6842                 }
6843                 default: abort();
6844         }
6845 }
6846 static inline LDKCVec_RecentPaymentDetailsZ CVec_RecentPaymentDetailsZ_clone(const LDKCVec_RecentPaymentDetailsZ *orig) {
6847         LDKCVec_RecentPaymentDetailsZ ret = { .data = MALLOC(sizeof(LDKRecentPaymentDetails) * orig->datalen, "LDKCVec_RecentPaymentDetailsZ clone bytes"), .datalen = orig->datalen };
6848         for (size_t i = 0; i < ret.datalen; i++) {
6849                 ret.data[i] = RecentPaymentDetails_clone(&orig->data[i]);
6850         }
6851         return ret;
6852 }
6853 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
6854 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
6855 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
6856 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
6857 static jclass LDKPaymentSendFailure_AllFailedResendSafe_class = NULL;
6858 static jmethodID LDKPaymentSendFailure_AllFailedResendSafe_meth = NULL;
6859 static jclass LDKPaymentSendFailure_DuplicatePayment_class = NULL;
6860 static jmethodID LDKPaymentSendFailure_DuplicatePayment_meth = NULL;
6861 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
6862 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
6863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
6864         LDKPaymentSendFailure_ParameterError_class =
6865                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
6866         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
6867         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
6868         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
6869         LDKPaymentSendFailure_PathParameterError_class =
6870                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
6871         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
6872         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
6873         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
6874         LDKPaymentSendFailure_AllFailedResendSafe_class =
6875                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedResendSafe"));
6876         CHECK(LDKPaymentSendFailure_AllFailedResendSafe_class != NULL);
6877         LDKPaymentSendFailure_AllFailedResendSafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedResendSafe_class, "<init>", "([J)V");
6878         CHECK(LDKPaymentSendFailure_AllFailedResendSafe_meth != NULL);
6879         LDKPaymentSendFailure_DuplicatePayment_class =
6880                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$DuplicatePayment"));
6881         CHECK(LDKPaymentSendFailure_DuplicatePayment_class != NULL);
6882         LDKPaymentSendFailure_DuplicatePayment_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_DuplicatePayment_class, "<init>", "()V");
6883         CHECK(LDKPaymentSendFailure_DuplicatePayment_meth != NULL);
6884         LDKPaymentSendFailure_PartialFailure_class =
6885                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
6886         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
6887         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
6888         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
6889 }
6890 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6891         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
6892         switch(obj->tag) {
6893                 case LDKPaymentSendFailure_ParameterError: {
6894                         int64_t parameter_error_ref = tag_ptr(&obj->parameter_error, false);
6895                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
6896                 }
6897                 case LDKPaymentSendFailure_PathParameterError: {
6898                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
6899                         int64_tArray path_parameter_error_arr = NULL;
6900                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
6901                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
6902                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
6903                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6904                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
6905                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
6906                                 path_parameter_error_arr_ptr[w] = tag_ptr(path_parameter_error_conv_22_conv, true);
6907                         }
6908                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
6909                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
6910                 }
6911                 case LDKPaymentSendFailure_AllFailedResendSafe: {
6912                         LDKCVec_APIErrorZ all_failed_resend_safe_var = obj->all_failed_resend_safe;
6913                         int64_tArray all_failed_resend_safe_arr = NULL;
6914                         all_failed_resend_safe_arr = (*env)->NewLongArray(env, all_failed_resend_safe_var.datalen);
6915                         int64_t *all_failed_resend_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_resend_safe_arr, NULL);
6916                         for (size_t k = 0; k < all_failed_resend_safe_var.datalen; k++) {
6917                                 int64_t all_failed_resend_safe_conv_10_ref = tag_ptr(&all_failed_resend_safe_var.data[k], false);
6918                                 all_failed_resend_safe_arr_ptr[k] = all_failed_resend_safe_conv_10_ref;
6919                         }
6920                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_resend_safe_arr, all_failed_resend_safe_arr_ptr, 0);
6921                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedResendSafe_class, LDKPaymentSendFailure_AllFailedResendSafe_meth, all_failed_resend_safe_arr);
6922                 }
6923                 case LDKPaymentSendFailure_DuplicatePayment: {
6924                         return (*env)->NewObject(env, LDKPaymentSendFailure_DuplicatePayment_class, LDKPaymentSendFailure_DuplicatePayment_meth);
6925                 }
6926                 case LDKPaymentSendFailure_PartialFailure: {
6927                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
6928                         int64_tArray results_arr = NULL;
6929                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
6930                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
6931                         for (size_t w = 0; w < results_var.datalen; w++) {
6932                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6933                                 *results_conv_22_conv = results_var.data[w];
6934                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
6935                                 results_arr_ptr[w] = tag_ptr(results_conv_22_conv, true);
6936                         }
6937                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
6938                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
6939                         int64_t failed_paths_retry_ref = 0;
6940                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
6941                         failed_paths_retry_ref = tag_ptr(failed_paths_retry_var.inner, false);
6942                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
6943                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
6944                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
6945                 }
6946                 default: abort();
6947         }
6948 }
6949 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6950 CHECK(owner->result_ok);
6951         return *owner->contents.result;
6952 }
6953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6954         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
6955         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
6956 }
6957
6958 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6959 CHECK(!owner->result_ok);
6960         return PaymentSendFailure_clone(&*owner->contents.err);
6961 }
6962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6963         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
6964         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6965         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
6966         int64_t ret_ref = tag_ptr(ret_copy, true);
6967         return ret_ref;
6968 }
6969
6970 static inline void CResult_NoneRetryableSendFailureZ_get_ok(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR owner){
6971 CHECK(owner->result_ok);
6972         return *owner->contents.result;
6973 }
6974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6975         LDKCResult_NoneRetryableSendFailureZ* owner_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(owner);
6976         CResult_NoneRetryableSendFailureZ_get_ok(owner_conv);
6977 }
6978
6979 static inline enum LDKRetryableSendFailure CResult_NoneRetryableSendFailureZ_get_err(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR owner){
6980 CHECK(!owner->result_ok);
6981         return RetryableSendFailure_clone(&*owner->contents.err);
6982 }
6983 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6984         LDKCResult_NoneRetryableSendFailureZ* owner_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(owner);
6985         jclass ret_conv = LDKRetryableSendFailure_to_java(env, CResult_NoneRetryableSendFailureZ_get_err(owner_conv));
6986         return ret_conv;
6987 }
6988
6989 static inline struct LDKThirtyTwoBytes CResult_PaymentHashPaymentSendFailureZ_get_ok(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR owner){
6990 CHECK(owner->result_ok);
6991         return ThirtyTwoBytes_clone(&*owner->contents.result);
6992 }
6993 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6994         LDKCResult_PaymentHashPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(owner);
6995         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6996         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentHashPaymentSendFailureZ_get_ok(owner_conv).data);
6997         return ret_arr;
6998 }
6999
7000 static inline struct LDKPaymentSendFailure CResult_PaymentHashPaymentSendFailureZ_get_err(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR owner){
7001 CHECK(!owner->result_ok);
7002         return PaymentSendFailure_clone(&*owner->contents.err);
7003 }
7004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7005         LDKCResult_PaymentHashPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(owner);
7006         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
7007         *ret_copy = CResult_PaymentHashPaymentSendFailureZ_get_err(owner_conv);
7008         int64_t ret_ref = tag_ptr(ret_copy, true);
7009         return ret_ref;
7010 }
7011
7012 static inline struct LDKThirtyTwoBytes CResult_PaymentHashRetryableSendFailureZ_get_ok(LDKCResult_PaymentHashRetryableSendFailureZ *NONNULL_PTR owner){
7013 CHECK(owner->result_ok);
7014         return ThirtyTwoBytes_clone(&*owner->contents.result);
7015 }
7016 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7017         LDKCResult_PaymentHashRetryableSendFailureZ* owner_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(owner);
7018         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7019         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentHashRetryableSendFailureZ_get_ok(owner_conv).data);
7020         return ret_arr;
7021 }
7022
7023 static inline enum LDKRetryableSendFailure CResult_PaymentHashRetryableSendFailureZ_get_err(LDKCResult_PaymentHashRetryableSendFailureZ *NONNULL_PTR owner){
7024 CHECK(!owner->result_ok);
7025         return RetryableSendFailure_clone(&*owner->contents.err);
7026 }
7027 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7028         LDKCResult_PaymentHashRetryableSendFailureZ* owner_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(owner);
7029         jclass ret_conv = LDKRetryableSendFailure_to_java(env, CResult_PaymentHashRetryableSendFailureZ_get_err(owner_conv));
7030         return ret_conv;
7031 }
7032
7033 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
7034         return ThirtyTwoBytes_clone(&owner->a);
7035 }
7036 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7037         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
7038         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7039         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
7040         return ret_arr;
7041 }
7042
7043 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
7044         return ThirtyTwoBytes_clone(&owner->b);
7045 }
7046 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7047         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
7048         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7049         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
7050         return ret_arr;
7051 }
7052
7053 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
7054 CHECK(owner->result_ok);
7055         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
7056 }
7057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7058         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
7059         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
7060         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
7061         return tag_ptr(ret_conv, true);
7062 }
7063
7064 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
7065 CHECK(!owner->result_ok);
7066         return PaymentSendFailure_clone(&*owner->contents.err);
7067 }
7068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7069         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
7070         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
7071         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
7072         int64_t ret_ref = tag_ptr(ret_copy, true);
7073         return ret_ref;
7074 }
7075
7076 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
7077         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
7078         for (size_t i = 0; i < ret.datalen; i++) {
7079                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
7080         }
7081         return ret;
7082 }
7083 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
7084         return ThirtyTwoBytes_clone(&owner->a);
7085 }
7086 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7087         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
7088         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7089         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
7090         return ret_arr;
7091 }
7092
7093 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
7094         return ThirtyTwoBytes_clone(&owner->b);
7095 }
7096 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7097         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
7098         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7099         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
7100         return ret_arr;
7101 }
7102
7103 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
7104 CHECK(owner->result_ok);
7105         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
7106 }
7107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7108         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
7109         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
7110         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
7111         return tag_ptr(ret_conv, true);
7112 }
7113
7114 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
7115 CHECK(!owner->result_ok);
7116         return *owner->contents.err;
7117 }
7118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7119         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
7120         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
7121 }
7122
7123 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
7124 CHECK(owner->result_ok);
7125         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
7126 }
7127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7128         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
7129         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
7130         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
7131         return tag_ptr(ret_conv, true);
7132 }
7133
7134 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
7135 CHECK(!owner->result_ok);
7136         return APIError_clone(&*owner->contents.err);
7137 }
7138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7139         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
7140         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
7141         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
7142         int64_t ret_ref = tag_ptr(ret_copy, true);
7143         return ret_ref;
7144 }
7145
7146 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
7147 CHECK(owner->result_ok);
7148         return ThirtyTwoBytes_clone(&*owner->contents.result);
7149 }
7150 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7151         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
7152         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7153         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
7154         return ret_arr;
7155 }
7156
7157 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
7158 CHECK(!owner->result_ok);
7159         return *owner->contents.err;
7160 }
7161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7162         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
7163         CResult_PaymentSecretNoneZ_get_err(owner_conv);
7164 }
7165
7166 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
7167 CHECK(owner->result_ok);
7168         return ThirtyTwoBytes_clone(&*owner->contents.result);
7169 }
7170 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7171         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
7172         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7173         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
7174         return ret_arr;
7175 }
7176
7177 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
7178 CHECK(!owner->result_ok);
7179         return APIError_clone(&*owner->contents.err);
7180 }
7181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7182         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
7183         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
7184         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
7185         int64_t ret_ref = tag_ptr(ret_copy, true);
7186         return ret_ref;
7187 }
7188
7189 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
7190 CHECK(owner->result_ok);
7191         return ThirtyTwoBytes_clone(&*owner->contents.result);
7192 }
7193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7194         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
7195         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7196         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
7197         return ret_arr;
7198 }
7199
7200 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
7201 CHECK(!owner->result_ok);
7202         return APIError_clone(&*owner->contents.err);
7203 }
7204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7205         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
7206         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
7207         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
7208         int64_t ret_ref = tag_ptr(ret_copy, true);
7209         return ret_ref;
7210 }
7211
7212 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
7213         LDKCounterpartyForwardingInfo ret = *owner->contents.result;
7214         ret.is_owned = false;
7215         return ret;
7216 }
7217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7218         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
7219         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
7220         int64_t ret_ref = 0;
7221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7222         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7223         return ret_ref;
7224 }
7225
7226 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
7227 CHECK(!owner->result_ok);
7228         return DecodeError_clone(&*owner->contents.err);
7229 }
7230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7231         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
7232         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7233         *ret_copy = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
7234         int64_t ret_ref = tag_ptr(ret_copy, true);
7235         return ret_ref;
7236 }
7237
7238 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
7239         LDKChannelCounterparty ret = *owner->contents.result;
7240         ret.is_owned = false;
7241         return ret;
7242 }
7243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7244         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
7245         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
7246         int64_t ret_ref = 0;
7247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7248         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7249         return ret_ref;
7250 }
7251
7252 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
7253 CHECK(!owner->result_ok);
7254         return DecodeError_clone(&*owner->contents.err);
7255 }
7256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7257         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
7258         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7259         *ret_copy = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
7260         int64_t ret_ref = tag_ptr(ret_copy, true);
7261         return ret_ref;
7262 }
7263
7264 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
7265         LDKChannelDetails ret = *owner->contents.result;
7266         ret.is_owned = false;
7267         return ret;
7268 }
7269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7270         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
7271         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
7272         int64_t ret_ref = 0;
7273         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7274         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7275         return ret_ref;
7276 }
7277
7278 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
7279 CHECK(!owner->result_ok);
7280         return DecodeError_clone(&*owner->contents.err);
7281 }
7282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7283         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
7284         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7285         *ret_copy = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
7286         int64_t ret_ref = tag_ptr(ret_copy, true);
7287         return ret_ref;
7288 }
7289
7290 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
7291         LDKPhantomRouteHints ret = *owner->contents.result;
7292         ret.is_owned = false;
7293         return ret;
7294 }
7295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7296         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
7297         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
7298         int64_t ret_ref = 0;
7299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7300         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7301         return ret_ref;
7302 }
7303
7304 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
7305 CHECK(!owner->result_ok);
7306         return DecodeError_clone(&*owner->contents.err);
7307 }
7308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7309         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
7310         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7311         *ret_copy = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
7312         int64_t ret_ref = tag_ptr(ret_copy, true);
7313         return ret_ref;
7314 }
7315
7316 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
7317         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
7318         for (size_t i = 0; i < ret.datalen; i++) {
7319                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
7320         }
7321         return ret;
7322 }
7323 typedef struct LDKWatch_JCalls {
7324         atomic_size_t refcnt;
7325         JavaVM *vm;
7326         jweak o;
7327         jmethodID watch_channel_meth;
7328         jmethodID update_channel_meth;
7329         jmethodID release_pending_monitor_events_meth;
7330 } LDKWatch_JCalls;
7331 static void LDKWatch_JCalls_free(void* this_arg) {
7332         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7333         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7334                 JNIEnv *env;
7335                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7336                 if (get_jenv_res == JNI_EDETACHED) {
7337                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7338                 } else {
7339                         DO_ASSERT(get_jenv_res == JNI_OK);
7340                 }
7341                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7342                 if (get_jenv_res == JNI_EDETACHED) {
7343                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7344                 }
7345                 FREE(j_calls);
7346         }
7347 }
7348 LDKChannelMonitorUpdateStatus watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
7349         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7350         JNIEnv *env;
7351         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7352         if (get_jenv_res == JNI_EDETACHED) {
7353                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7354         } else {
7355                 DO_ASSERT(get_jenv_res == JNI_OK);
7356         }
7357         LDKOutPoint funding_txo_var = funding_txo;
7358         int64_t funding_txo_ref = 0;
7359         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
7360         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
7361         LDKChannelMonitor monitor_var = monitor;
7362         int64_t monitor_ref = 0;
7363         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
7364         monitor_ref = tag_ptr(monitor_var.inner, monitor_var.is_owned);
7365         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7366         CHECK(obj != NULL);
7367         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
7368         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7369                 (*env)->ExceptionDescribe(env);
7370                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
7371         }
7372         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
7373         if (get_jenv_res == JNI_EDETACHED) {
7374                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7375         }
7376         return ret_conv;
7377 }
7378 LDKChannelMonitorUpdateStatus update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, const LDKChannelMonitorUpdate * update) {
7379         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7380         JNIEnv *env;
7381         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7382         if (get_jenv_res == JNI_EDETACHED) {
7383                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7384         } else {
7385                 DO_ASSERT(get_jenv_res == JNI_OK);
7386         }
7387         LDKOutPoint funding_txo_var = funding_txo;
7388         int64_t funding_txo_ref = 0;
7389         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
7390         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
7391         LDKChannelMonitorUpdate update_var = *update;
7392         int64_t update_ref = 0;
7393         update_var = ChannelMonitorUpdate_clone(&update_var);
7394         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
7395         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
7396         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7397         CHECK(obj != NULL);
7398         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
7399         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7400                 (*env)->ExceptionDescribe(env);
7401                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
7402         }
7403         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
7404         if (get_jenv_res == JNI_EDETACHED) {
7405                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7406         }
7407         return ret_conv;
7408 }
7409 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
7410         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7411         JNIEnv *env;
7412         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7413         if (get_jenv_res == JNI_EDETACHED) {
7414                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7415         } else {
7416                 DO_ASSERT(get_jenv_res == JNI_OK);
7417         }
7418         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7419         CHECK(obj != NULL);
7420         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
7421         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7422                 (*env)->ExceptionDescribe(env);
7423                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
7424         }
7425         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
7426         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7427         if (ret_constr.datalen > 0)
7428                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
7429         else
7430                 ret_constr.data = NULL;
7431         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7432         for (size_t x = 0; x < ret_constr.datalen; x++) {
7433                 int64_t ret_conv_49 = ret_vals[x];
7434                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
7435                 CHECK_ACCESS(ret_conv_49_ptr);
7436                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
7437                 FREE(untag_ptr(ret_conv_49));
7438                 ret_constr.data[x] = ret_conv_49_conv;
7439         }
7440         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7441         if (get_jenv_res == JNI_EDETACHED) {
7442                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7443         }
7444         return ret_constr;
7445 }
7446 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
7447         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
7448         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7449 }
7450 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
7451         jclass c = (*env)->GetObjectClass(env, o);
7452         CHECK(c != NULL);
7453         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
7454         atomic_init(&calls->refcnt, 1);
7455         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7456         calls->o = (*env)->NewWeakGlobalRef(env, o);
7457         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
7458         CHECK(calls->watch_channel_meth != NULL);
7459         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
7460         CHECK(calls->update_channel_meth != NULL);
7461         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
7462         CHECK(calls->release_pending_monitor_events_meth != NULL);
7463
7464         LDKWatch ret = {
7465                 .this_arg = (void*) calls,
7466                 .watch_channel = watch_channel_LDKWatch_jcall,
7467                 .update_channel = update_channel_LDKWatch_jcall,
7468                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
7469                 .free = LDKWatch_JCalls_free,
7470         };
7471         return ret;
7472 }
7473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
7474         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
7475         *res_ptr = LDKWatch_init(env, clz, o);
7476         return tag_ptr(res_ptr, true);
7477 }
7478 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) {
7479         void* this_arg_ptr = untag_ptr(this_arg);
7480         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7481         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7482         LDKOutPoint funding_txo_conv;
7483         funding_txo_conv.inner = untag_ptr(funding_txo);
7484         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
7485         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
7486         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
7487         LDKChannelMonitor monitor_conv;
7488         monitor_conv.inner = untag_ptr(monitor);
7489         monitor_conv.is_owned = ptr_is_owned(monitor);
7490         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
7491         monitor_conv = ChannelMonitor_clone(&monitor_conv);
7492         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv));
7493         return ret_conv;
7494 }
7495
7496 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) {
7497         void* this_arg_ptr = untag_ptr(this_arg);
7498         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7499         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7500         LDKOutPoint funding_txo_conv;
7501         funding_txo_conv.inner = untag_ptr(funding_txo);
7502         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
7503         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
7504         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
7505         LDKChannelMonitorUpdate update_conv;
7506         update_conv.inner = untag_ptr(update);
7507         update_conv.is_owned = ptr_is_owned(update);
7508         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
7509         update_conv.is_owned = false;
7510         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, &update_conv));
7511         return ret_conv;
7512 }
7513
7514 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
7515         void* this_arg_ptr = untag_ptr(this_arg);
7516         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7517         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7518         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
7519         int64_tArray ret_arr = NULL;
7520         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7521         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7522         for (size_t x = 0; x < ret_var.datalen; x++) {
7523                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
7524                 *ret_conv_49_conv = ret_var.data[x];
7525                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
7526         }
7527         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7528         FREE(ret_var.data);
7529         return ret_arr;
7530 }
7531
7532 typedef struct LDKBroadcasterInterface_JCalls {
7533         atomic_size_t refcnt;
7534         JavaVM *vm;
7535         jweak o;
7536         jmethodID broadcast_transaction_meth;
7537 } LDKBroadcasterInterface_JCalls;
7538 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
7539         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7540         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7541                 JNIEnv *env;
7542                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7543                 if (get_jenv_res == JNI_EDETACHED) {
7544                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7545                 } else {
7546                         DO_ASSERT(get_jenv_res == JNI_OK);
7547                 }
7548                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7549                 if (get_jenv_res == JNI_EDETACHED) {
7550                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7551                 }
7552                 FREE(j_calls);
7553         }
7554 }
7555 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
7556         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7557         JNIEnv *env;
7558         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7559         if (get_jenv_res == JNI_EDETACHED) {
7560                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7561         } else {
7562                 DO_ASSERT(get_jenv_res == JNI_OK);
7563         }
7564         LDKTransaction tx_var = tx;
7565         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
7566         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
7567         Transaction_free(tx_var);
7568         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7569         CHECK(obj != NULL);
7570         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
7571         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7572                 (*env)->ExceptionDescribe(env);
7573                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
7574         }
7575         if (get_jenv_res == JNI_EDETACHED) {
7576                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7577         }
7578 }
7579 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
7580         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
7581         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7582 }
7583 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
7584         jclass c = (*env)->GetObjectClass(env, o);
7585         CHECK(c != NULL);
7586         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
7587         atomic_init(&calls->refcnt, 1);
7588         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7589         calls->o = (*env)->NewWeakGlobalRef(env, o);
7590         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
7591         CHECK(calls->broadcast_transaction_meth != NULL);
7592
7593         LDKBroadcasterInterface ret = {
7594                 .this_arg = (void*) calls,
7595                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
7596                 .free = LDKBroadcasterInterface_JCalls_free,
7597         };
7598         return ret;
7599 }
7600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7601         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
7602         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
7603         return tag_ptr(res_ptr, true);
7604 }
7605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
7606         void* this_arg_ptr = untag_ptr(this_arg);
7607         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7608         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
7609         LDKTransaction tx_ref;
7610         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
7611         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
7612         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
7613         tx_ref.data_is_owned = true;
7614         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
7615 }
7616
7617 typedef struct LDKEntropySource_JCalls {
7618         atomic_size_t refcnt;
7619         JavaVM *vm;
7620         jweak o;
7621         jmethodID get_secure_random_bytes_meth;
7622 } LDKEntropySource_JCalls;
7623 static void LDKEntropySource_JCalls_free(void* this_arg) {
7624         LDKEntropySource_JCalls *j_calls = (LDKEntropySource_JCalls*) this_arg;
7625         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7626                 JNIEnv *env;
7627                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7628                 if (get_jenv_res == JNI_EDETACHED) {
7629                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7630                 } else {
7631                         DO_ASSERT(get_jenv_res == JNI_OK);
7632                 }
7633                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7634                 if (get_jenv_res == JNI_EDETACHED) {
7635                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7636                 }
7637                 FREE(j_calls);
7638         }
7639 }
7640 LDKThirtyTwoBytes get_secure_random_bytes_LDKEntropySource_jcall(const void* this_arg) {
7641         LDKEntropySource_JCalls *j_calls = (LDKEntropySource_JCalls*) this_arg;
7642         JNIEnv *env;
7643         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7644         if (get_jenv_res == JNI_EDETACHED) {
7645                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7646         } else {
7647                 DO_ASSERT(get_jenv_res == JNI_OK);
7648         }
7649         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7650         CHECK(obj != NULL);
7651         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
7652         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7653                 (*env)->ExceptionDescribe(env);
7654                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKEntropySource from rust threw an exception.");
7655         }
7656         LDKThirtyTwoBytes ret_ref;
7657         CHECK((*env)->GetArrayLength(env, ret) == 32);
7658         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7659         if (get_jenv_res == JNI_EDETACHED) {
7660                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7661         }
7662         return ret_ref;
7663 }
7664 static void LDKEntropySource_JCalls_cloned(LDKEntropySource* new_obj) {
7665         LDKEntropySource_JCalls *j_calls = (LDKEntropySource_JCalls*) new_obj->this_arg;
7666         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7667 }
7668 static inline LDKEntropySource LDKEntropySource_init (JNIEnv *env, jclass clz, jobject o) {
7669         jclass c = (*env)->GetObjectClass(env, o);
7670         CHECK(c != NULL);
7671         LDKEntropySource_JCalls *calls = MALLOC(sizeof(LDKEntropySource_JCalls), "LDKEntropySource_JCalls");
7672         atomic_init(&calls->refcnt, 1);
7673         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7674         calls->o = (*env)->NewWeakGlobalRef(env, o);
7675         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
7676         CHECK(calls->get_secure_random_bytes_meth != NULL);
7677
7678         LDKEntropySource ret = {
7679                 .this_arg = (void*) calls,
7680                 .get_secure_random_bytes = get_secure_random_bytes_LDKEntropySource_jcall,
7681                 .free = LDKEntropySource_JCalls_free,
7682         };
7683         return ret;
7684 }
7685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEntropySource_1new(JNIEnv *env, jclass clz, jobject o) {
7686         LDKEntropySource *res_ptr = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
7687         *res_ptr = LDKEntropySource_init(env, clz, o);
7688         return tag_ptr(res_ptr, true);
7689 }
7690 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_EntropySource_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
7691         void* this_arg_ptr = untag_ptr(this_arg);
7692         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7693         LDKEntropySource* this_arg_conv = (LDKEntropySource*)this_arg_ptr;
7694         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7695         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
7696         return ret_arr;
7697 }
7698
7699 static jclass LDKUnsignedGossipMessage_ChannelAnnouncement_class = NULL;
7700 static jmethodID LDKUnsignedGossipMessage_ChannelAnnouncement_meth = NULL;
7701 static jclass LDKUnsignedGossipMessage_ChannelUpdate_class = NULL;
7702 static jmethodID LDKUnsignedGossipMessage_ChannelUpdate_meth = NULL;
7703 static jclass LDKUnsignedGossipMessage_NodeAnnouncement_class = NULL;
7704 static jmethodID LDKUnsignedGossipMessage_NodeAnnouncement_meth = NULL;
7705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKUnsignedGossipMessage_init (JNIEnv *env, jclass clz) {
7706         LDKUnsignedGossipMessage_ChannelAnnouncement_class =
7707                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKUnsignedGossipMessage$ChannelAnnouncement"));
7708         CHECK(LDKUnsignedGossipMessage_ChannelAnnouncement_class != NULL);
7709         LDKUnsignedGossipMessage_ChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKUnsignedGossipMessage_ChannelAnnouncement_class, "<init>", "(J)V");
7710         CHECK(LDKUnsignedGossipMessage_ChannelAnnouncement_meth != NULL);
7711         LDKUnsignedGossipMessage_ChannelUpdate_class =
7712                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKUnsignedGossipMessage$ChannelUpdate"));
7713         CHECK(LDKUnsignedGossipMessage_ChannelUpdate_class != NULL);
7714         LDKUnsignedGossipMessage_ChannelUpdate_meth = (*env)->GetMethodID(env, LDKUnsignedGossipMessage_ChannelUpdate_class, "<init>", "(J)V");
7715         CHECK(LDKUnsignedGossipMessage_ChannelUpdate_meth != NULL);
7716         LDKUnsignedGossipMessage_NodeAnnouncement_class =
7717                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKUnsignedGossipMessage$NodeAnnouncement"));
7718         CHECK(LDKUnsignedGossipMessage_NodeAnnouncement_class != NULL);
7719         LDKUnsignedGossipMessage_NodeAnnouncement_meth = (*env)->GetMethodID(env, LDKUnsignedGossipMessage_NodeAnnouncement_class, "<init>", "(J)V");
7720         CHECK(LDKUnsignedGossipMessage_NodeAnnouncement_meth != NULL);
7721 }
7722 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKUnsignedGossipMessage_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7723         LDKUnsignedGossipMessage *obj = (LDKUnsignedGossipMessage*)untag_ptr(ptr);
7724         switch(obj->tag) {
7725                 case LDKUnsignedGossipMessage_ChannelAnnouncement: {
7726                         LDKUnsignedChannelAnnouncement channel_announcement_var = obj->channel_announcement;
7727                         int64_t channel_announcement_ref = 0;
7728                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_announcement_var);
7729                         channel_announcement_ref = tag_ptr(channel_announcement_var.inner, false);
7730                         return (*env)->NewObject(env, LDKUnsignedGossipMessage_ChannelAnnouncement_class, LDKUnsignedGossipMessage_ChannelAnnouncement_meth, channel_announcement_ref);
7731                 }
7732                 case LDKUnsignedGossipMessage_ChannelUpdate: {
7733                         LDKUnsignedChannelUpdate channel_update_var = obj->channel_update;
7734                         int64_t channel_update_ref = 0;
7735                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_update_var);
7736                         channel_update_ref = tag_ptr(channel_update_var.inner, false);
7737                         return (*env)->NewObject(env, LDKUnsignedGossipMessage_ChannelUpdate_class, LDKUnsignedGossipMessage_ChannelUpdate_meth, channel_update_ref);
7738                 }
7739                 case LDKUnsignedGossipMessage_NodeAnnouncement: {
7740                         LDKUnsignedNodeAnnouncement node_announcement_var = obj->node_announcement;
7741                         int64_t node_announcement_ref = 0;
7742                         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_announcement_var);
7743                         node_announcement_ref = tag_ptr(node_announcement_var.inner, false);
7744                         return (*env)->NewObject(env, LDKUnsignedGossipMessage_NodeAnnouncement_class, LDKUnsignedGossipMessage_NodeAnnouncement_meth, node_announcement_ref);
7745                 }
7746                 default: abort();
7747         }
7748 }
7749 typedef struct LDKNodeSigner_JCalls {
7750         atomic_size_t refcnt;
7751         JavaVM *vm;
7752         jweak o;
7753         jmethodID get_inbound_payment_key_material_meth;
7754         jmethodID get_node_id_meth;
7755         jmethodID ecdh_meth;
7756         jmethodID sign_invoice_meth;
7757         jmethodID sign_gossip_message_meth;
7758 } LDKNodeSigner_JCalls;
7759 static void LDKNodeSigner_JCalls_free(void* this_arg) {
7760         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
7761         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7762                 JNIEnv *env;
7763                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7764                 if (get_jenv_res == JNI_EDETACHED) {
7765                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7766                 } else {
7767                         DO_ASSERT(get_jenv_res == JNI_OK);
7768                 }
7769                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7770                 if (get_jenv_res == JNI_EDETACHED) {
7771                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7772                 }
7773                 FREE(j_calls);
7774         }
7775 }
7776 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKNodeSigner_jcall(const void* this_arg) {
7777         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
7778         JNIEnv *env;
7779         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7780         if (get_jenv_res == JNI_EDETACHED) {
7781                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7782         } else {
7783                 DO_ASSERT(get_jenv_res == JNI_OK);
7784         }
7785         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7786         CHECK(obj != NULL);
7787         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
7788         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7789                 (*env)->ExceptionDescribe(env);
7790                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKNodeSigner from rust threw an exception.");
7791         }
7792         LDKThirtyTwoBytes ret_ref;
7793         CHECK((*env)->GetArrayLength(env, ret) == 32);
7794         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7795         if (get_jenv_res == JNI_EDETACHED) {
7796                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7797         }
7798         return ret_ref;
7799 }
7800 LDKCResult_PublicKeyNoneZ get_node_id_LDKNodeSigner_jcall(const void* this_arg, LDKRecipient recipient) {
7801         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
7802         JNIEnv *env;
7803         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7804         if (get_jenv_res == JNI_EDETACHED) {
7805                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7806         } else {
7807                 DO_ASSERT(get_jenv_res == JNI_OK);
7808         }
7809         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7810         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7811         CHECK(obj != NULL);
7812         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_id_meth, recipient_conv);
7813         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7814                 (*env)->ExceptionDescribe(env);
7815                 (*env)->FatalError(env, "A call to get_node_id in LDKNodeSigner from rust threw an exception.");
7816         }
7817         void* ret_ptr = untag_ptr(ret);
7818         CHECK_ACCESS(ret_ptr);
7819         LDKCResult_PublicKeyNoneZ ret_conv = *(LDKCResult_PublicKeyNoneZ*)(ret_ptr);
7820         FREE(untag_ptr(ret));
7821         if (get_jenv_res == JNI_EDETACHED) {
7822                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7823         }
7824         return ret_conv;
7825 }
7826 LDKCResult_SharedSecretNoneZ ecdh_LDKNodeSigner_jcall(const void* this_arg, LDKRecipient recipient, LDKPublicKey other_key, LDKCOption_ScalarZ tweak) {
7827         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
7828         JNIEnv *env;
7829         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7830         if (get_jenv_res == JNI_EDETACHED) {
7831                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7832         } else {
7833                 DO_ASSERT(get_jenv_res == JNI_OK);
7834         }
7835         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7836         int8_tArray other_key_arr = (*env)->NewByteArray(env, 33);
7837         (*env)->SetByteArrayRegion(env, other_key_arr, 0, 33, other_key.compressed_form);
7838         LDKCOption_ScalarZ *tweak_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
7839         *tweak_copy = tweak;
7840         int64_t tweak_ref = tag_ptr(tweak_copy, true);
7841         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7842         CHECK(obj != NULL);
7843         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->ecdh_meth, recipient_conv, other_key_arr, tweak_ref);
7844         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7845                 (*env)->ExceptionDescribe(env);
7846                 (*env)->FatalError(env, "A call to ecdh in LDKNodeSigner from rust threw an exception.");
7847         }
7848         void* ret_ptr = untag_ptr(ret);
7849         CHECK_ACCESS(ret_ptr);
7850         LDKCResult_SharedSecretNoneZ ret_conv = *(LDKCResult_SharedSecretNoneZ*)(ret_ptr);
7851         FREE(untag_ptr(ret));
7852         if (get_jenv_res == JNI_EDETACHED) {
7853                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7854         }
7855         return ret_conv;
7856 }
7857 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKNodeSigner_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_U5Z invoice_data, LDKRecipient recipient) {
7858         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
7859         JNIEnv *env;
7860         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7861         if (get_jenv_res == JNI_EDETACHED) {
7862                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7863         } else {
7864                 DO_ASSERT(get_jenv_res == JNI_OK);
7865         }
7866         LDKu8slice hrp_bytes_var = hrp_bytes;
7867         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
7868         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
7869         LDKCVec_U5Z invoice_data_var = invoice_data;
7870         jobjectArray invoice_data_arr = NULL;
7871         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
7872         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
7873         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
7874                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
7875                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
7876         }
7877         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
7878         FREE(invoice_data_var.data);
7879         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7880         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7881         CHECK(obj != NULL);
7882         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, recipient_conv);
7883         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7884                 (*env)->ExceptionDescribe(env);
7885                 (*env)->FatalError(env, "A call to sign_invoice in LDKNodeSigner from rust threw an exception.");
7886         }
7887         void* ret_ptr = untag_ptr(ret);
7888         CHECK_ACCESS(ret_ptr);
7889         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
7890         FREE(untag_ptr(ret));
7891         if (get_jenv_res == JNI_EDETACHED) {
7892                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7893         }
7894         return ret_conv;
7895 }
7896 LDKCResult_SignatureNoneZ sign_gossip_message_LDKNodeSigner_jcall(const void* this_arg, LDKUnsignedGossipMessage msg) {
7897         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
7898         JNIEnv *env;
7899         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7900         if (get_jenv_res == JNI_EDETACHED) {
7901                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7902         } else {
7903                 DO_ASSERT(get_jenv_res == JNI_OK);
7904         }
7905         LDKUnsignedGossipMessage *msg_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
7906         *msg_copy = msg;
7907         int64_t msg_ref = tag_ptr(msg_copy, true);
7908         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7909         CHECK(obj != NULL);
7910         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_gossip_message_meth, msg_ref);
7911         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7912                 (*env)->ExceptionDescribe(env);
7913                 (*env)->FatalError(env, "A call to sign_gossip_message in LDKNodeSigner from rust threw an exception.");
7914         }
7915         void* ret_ptr = untag_ptr(ret);
7916         CHECK_ACCESS(ret_ptr);
7917         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
7918         FREE(untag_ptr(ret));
7919         if (get_jenv_res == JNI_EDETACHED) {
7920                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7921         }
7922         return ret_conv;
7923 }
7924 static void LDKNodeSigner_JCalls_cloned(LDKNodeSigner* new_obj) {
7925         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) new_obj->this_arg;
7926         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7927 }
7928 static inline LDKNodeSigner LDKNodeSigner_init (JNIEnv *env, jclass clz, jobject o) {
7929         jclass c = (*env)->GetObjectClass(env, o);
7930         CHECK(c != NULL);
7931         LDKNodeSigner_JCalls *calls = MALLOC(sizeof(LDKNodeSigner_JCalls), "LDKNodeSigner_JCalls");
7932         atomic_init(&calls->refcnt, 1);
7933         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7934         calls->o = (*env)->NewWeakGlobalRef(env, o);
7935         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
7936         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
7937         calls->get_node_id_meth = (*env)->GetMethodID(env, c, "get_node_id", "(Lorg/ldk/enums/Recipient;)J");
7938         CHECK(calls->get_node_id_meth != NULL);
7939         calls->ecdh_meth = (*env)->GetMethodID(env, c, "ecdh", "(Lorg/ldk/enums/Recipient;[BJ)J");
7940         CHECK(calls->ecdh_meth != NULL);
7941         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
7942         CHECK(calls->sign_invoice_meth != NULL);
7943         calls->sign_gossip_message_meth = (*env)->GetMethodID(env, c, "sign_gossip_message", "(J)J");
7944         CHECK(calls->sign_gossip_message_meth != NULL);
7945
7946         LDKNodeSigner ret = {
7947                 .this_arg = (void*) calls,
7948                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKNodeSigner_jcall,
7949                 .get_node_id = get_node_id_LDKNodeSigner_jcall,
7950                 .ecdh = ecdh_LDKNodeSigner_jcall,
7951                 .sign_invoice = sign_invoice_LDKNodeSigner_jcall,
7952                 .sign_gossip_message = sign_gossip_message_LDKNodeSigner_jcall,
7953                 .free = LDKNodeSigner_JCalls_free,
7954         };
7955         return ret;
7956 }
7957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKNodeSigner_1new(JNIEnv *env, jclass clz, jobject o) {
7958         LDKNodeSigner *res_ptr = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
7959         *res_ptr = LDKNodeSigner_init(env, clz, o);
7960         return tag_ptr(res_ptr, true);
7961 }
7962 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeSigner_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
7963         void* this_arg_ptr = untag_ptr(this_arg);
7964         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7965         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
7966         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7967         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
7968         return ret_arr;
7969 }
7970
7971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeSigner_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
7972         void* this_arg_ptr = untag_ptr(this_arg);
7973         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7974         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
7975         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7976         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
7977         *ret_conv = (this_arg_conv->get_node_id)(this_arg_conv->this_arg, recipient_conv);
7978         return tag_ptr(ret_conv, true);
7979 }
7980
7981 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) {
7982         void* this_arg_ptr = untag_ptr(this_arg);
7983         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7984         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
7985         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7986         LDKPublicKey other_key_ref;
7987         CHECK((*env)->GetArrayLength(env, other_key) == 33);
7988         (*env)->GetByteArrayRegion(env, other_key, 0, 33, other_key_ref.compressed_form);
7989         void* tweak_ptr = untag_ptr(tweak);
7990         CHECK_ACCESS(tweak_ptr);
7991         LDKCOption_ScalarZ tweak_conv = *(LDKCOption_ScalarZ*)(tweak_ptr);
7992         // WARNING: we may need a move here but no clone is available for LDKCOption_ScalarZ
7993         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
7994         *ret_conv = (this_arg_conv->ecdh)(this_arg_conv->this_arg, recipient_conv, other_key_ref, tweak_conv);
7995         return tag_ptr(ret_conv, true);
7996 }
7997
7998 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) {
7999         void* this_arg_ptr = untag_ptr(this_arg);
8000         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8001         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
8002         LDKu8slice hrp_bytes_ref;
8003         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
8004         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
8005         LDKCVec_U5Z invoice_data_constr;
8006         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
8007         if (invoice_data_constr.datalen > 0)
8008                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
8009         else
8010                 invoice_data_constr.data = NULL;
8011         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
8012         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
8013                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
8014                 
8015                 invoice_data_constr.data[h] = (LDKU5){ ._0 = invoice_data_conv_7 };
8016         }
8017         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
8018         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
8019         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
8020         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, recipient_conv);
8021         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
8022         return tag_ptr(ret_conv, true);
8023 }
8024
8025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeSigner_1sign_1gossip_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8026         void* this_arg_ptr = untag_ptr(this_arg);
8027         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8028         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
8029         void* msg_ptr = untag_ptr(msg);
8030         CHECK_ACCESS(msg_ptr);
8031         LDKUnsignedGossipMessage msg_conv = *(LDKUnsignedGossipMessage*)(msg_ptr);
8032         msg_conv = UnsignedGossipMessage_clone((LDKUnsignedGossipMessage*)untag_ptr(msg));
8033         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8034         *ret_conv = (this_arg_conv->sign_gossip_message)(this_arg_conv->this_arg, msg_conv);
8035         return tag_ptr(ret_conv, true);
8036 }
8037
8038 typedef struct LDKSignerProvider_JCalls {
8039         atomic_size_t refcnt;
8040         JavaVM *vm;
8041         jweak o;
8042         jmethodID generate_channel_keys_id_meth;
8043         jmethodID derive_channel_signer_meth;
8044         jmethodID read_chan_signer_meth;
8045         jmethodID get_destination_script_meth;
8046         jmethodID get_shutdown_scriptpubkey_meth;
8047 } LDKSignerProvider_JCalls;
8048 static void LDKSignerProvider_JCalls_free(void* this_arg) {
8049         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8050         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8051                 JNIEnv *env;
8052                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8053                 if (get_jenv_res == JNI_EDETACHED) {
8054                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8055                 } else {
8056                         DO_ASSERT(get_jenv_res == JNI_OK);
8057                 }
8058                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8059                 if (get_jenv_res == JNI_EDETACHED) {
8060                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8061                 }
8062                 FREE(j_calls);
8063         }
8064 }
8065 LDKThirtyTwoBytes generate_channel_keys_id_LDKSignerProvider_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis, LDKU128 user_channel_id) {
8066         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8067         JNIEnv *env;
8068         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8069         if (get_jenv_res == JNI_EDETACHED) {
8070                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8071         } else {
8072                 DO_ASSERT(get_jenv_res == JNI_OK);
8073         }
8074         jboolean inbound_conv = inbound;
8075         int64_t channel_value_satoshis_conv = channel_value_satoshis;
8076         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
8077         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, user_channel_id.le_bytes);
8078         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8079         CHECK(obj != NULL);
8080         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->generate_channel_keys_id_meth, inbound_conv, channel_value_satoshis_conv, user_channel_id_arr);
8081         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8082                 (*env)->ExceptionDescribe(env);
8083                 (*env)->FatalError(env, "A call to generate_channel_keys_id in LDKSignerProvider from rust threw an exception.");
8084         }
8085         LDKThirtyTwoBytes ret_ref;
8086         CHECK((*env)->GetArrayLength(env, ret) == 32);
8087         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
8088         if (get_jenv_res == JNI_EDETACHED) {
8089                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8090         }
8091         return ret_ref;
8092 }
8093 LDKWriteableEcdsaChannelSigner derive_channel_signer_LDKSignerProvider_jcall(const void* this_arg, uint64_t channel_value_satoshis, LDKThirtyTwoBytes channel_keys_id) {
8094         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8095         JNIEnv *env;
8096         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8097         if (get_jenv_res == JNI_EDETACHED) {
8098                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8099         } else {
8100                 DO_ASSERT(get_jenv_res == JNI_OK);
8101         }
8102         int64_t channel_value_satoshis_conv = channel_value_satoshis;
8103         int8_tArray channel_keys_id_arr = (*env)->NewByteArray(env, 32);
8104         (*env)->SetByteArrayRegion(env, channel_keys_id_arr, 0, 32, channel_keys_id.data);
8105         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8106         CHECK(obj != NULL);
8107         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->derive_channel_signer_meth, channel_value_satoshis_conv, channel_keys_id_arr);
8108         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8109                 (*env)->ExceptionDescribe(env);
8110                 (*env)->FatalError(env, "A call to derive_channel_signer in LDKSignerProvider from rust threw an exception.");
8111         }
8112         void* ret_ptr = untag_ptr(ret);
8113         CHECK_ACCESS(ret_ptr);
8114         LDKWriteableEcdsaChannelSigner ret_conv = *(LDKWriteableEcdsaChannelSigner*)(ret_ptr);
8115         FREE(untag_ptr(ret));
8116         if (get_jenv_res == JNI_EDETACHED) {
8117                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8118         }
8119         return ret_conv;
8120 }
8121 LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ read_chan_signer_LDKSignerProvider_jcall(const void* this_arg, LDKu8slice reader) {
8122         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8123         JNIEnv *env;
8124         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8125         if (get_jenv_res == JNI_EDETACHED) {
8126                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8127         } else {
8128                 DO_ASSERT(get_jenv_res == JNI_OK);
8129         }
8130         LDKu8slice reader_var = reader;
8131         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
8132         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
8133         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8134         CHECK(obj != NULL);
8135         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
8136         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8137                 (*env)->ExceptionDescribe(env);
8138                 (*env)->FatalError(env, "A call to read_chan_signer in LDKSignerProvider from rust threw an exception.");
8139         }
8140         void* ret_ptr = untag_ptr(ret);
8141         CHECK_ACCESS(ret_ptr);
8142         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ ret_conv = *(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)(ret_ptr);
8143         FREE(untag_ptr(ret));
8144         if (get_jenv_res == JNI_EDETACHED) {
8145                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8146         }
8147         return ret_conv;
8148 }
8149 LDKCVec_u8Z get_destination_script_LDKSignerProvider_jcall(const void* this_arg) {
8150         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8151         JNIEnv *env;
8152         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8153         if (get_jenv_res == JNI_EDETACHED) {
8154                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8155         } else {
8156                 DO_ASSERT(get_jenv_res == JNI_OK);
8157         }
8158         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8159         CHECK(obj != NULL);
8160         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
8161         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8162                 (*env)->ExceptionDescribe(env);
8163                 (*env)->FatalError(env, "A call to get_destination_script in LDKSignerProvider from rust threw an exception.");
8164         }
8165         LDKCVec_u8Z ret_ref;
8166         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
8167         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8168         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
8169         if (get_jenv_res == JNI_EDETACHED) {
8170                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8171         }
8172         return ret_ref;
8173 }
8174 LDKShutdownScript get_shutdown_scriptpubkey_LDKSignerProvider_jcall(const void* this_arg) {
8175         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8176         JNIEnv *env;
8177         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8178         if (get_jenv_res == JNI_EDETACHED) {
8179                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8180         } else {
8181                 DO_ASSERT(get_jenv_res == JNI_OK);
8182         }
8183         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8184         CHECK(obj != NULL);
8185         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
8186         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8187                 (*env)->ExceptionDescribe(env);
8188                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKSignerProvider from rust threw an exception.");
8189         }
8190         LDKShutdownScript ret_conv;
8191         ret_conv.inner = untag_ptr(ret);
8192         ret_conv.is_owned = ptr_is_owned(ret);
8193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
8194         if (get_jenv_res == JNI_EDETACHED) {
8195                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8196         }
8197         return ret_conv;
8198 }
8199 static void LDKSignerProvider_JCalls_cloned(LDKSignerProvider* new_obj) {
8200         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) new_obj->this_arg;
8201         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8202 }
8203 static inline LDKSignerProvider LDKSignerProvider_init (JNIEnv *env, jclass clz, jobject o) {
8204         jclass c = (*env)->GetObjectClass(env, o);
8205         CHECK(c != NULL);
8206         LDKSignerProvider_JCalls *calls = MALLOC(sizeof(LDKSignerProvider_JCalls), "LDKSignerProvider_JCalls");
8207         atomic_init(&calls->refcnt, 1);
8208         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8209         calls->o = (*env)->NewWeakGlobalRef(env, o);
8210         calls->generate_channel_keys_id_meth = (*env)->GetMethodID(env, c, "generate_channel_keys_id", "(ZJ[B)[B");
8211         CHECK(calls->generate_channel_keys_id_meth != NULL);
8212         calls->derive_channel_signer_meth = (*env)->GetMethodID(env, c, "derive_channel_signer", "(J[B)J");
8213         CHECK(calls->derive_channel_signer_meth != NULL);
8214         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
8215         CHECK(calls->read_chan_signer_meth != NULL);
8216         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
8217         CHECK(calls->get_destination_script_meth != NULL);
8218         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
8219         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
8220
8221         LDKSignerProvider ret = {
8222                 .this_arg = (void*) calls,
8223                 .generate_channel_keys_id = generate_channel_keys_id_LDKSignerProvider_jcall,
8224                 .derive_channel_signer = derive_channel_signer_LDKSignerProvider_jcall,
8225                 .read_chan_signer = read_chan_signer_LDKSignerProvider_jcall,
8226                 .get_destination_script = get_destination_script_LDKSignerProvider_jcall,
8227                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKSignerProvider_jcall,
8228                 .free = LDKSignerProvider_JCalls_free,
8229         };
8230         return ret;
8231 }
8232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSignerProvider_1new(JNIEnv *env, jclass clz, jobject o) {
8233         LDKSignerProvider *res_ptr = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
8234         *res_ptr = LDKSignerProvider_init(env, clz, o);
8235         return tag_ptr(res_ptr, true);
8236 }
8237 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) {
8238         void* this_arg_ptr = untag_ptr(this_arg);
8239         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8240         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
8241         LDKU128 user_channel_id_ref;
8242         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
8243         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
8244         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8245         (*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);
8246         return ret_arr;
8247 }
8248
8249 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) {
8250         void* this_arg_ptr = untag_ptr(this_arg);
8251         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8252         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
8253         LDKThirtyTwoBytes channel_keys_id_ref;
8254         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
8255         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
8256         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
8257         *ret_ret = (this_arg_conv->derive_channel_signer)(this_arg_conv->this_arg, channel_value_satoshis, channel_keys_id_ref);
8258         return tag_ptr(ret_ret, true);
8259 }
8260
8261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignerProvider_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
8262         void* this_arg_ptr = untag_ptr(this_arg);
8263         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8264         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
8265         LDKu8slice reader_ref;
8266         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
8267         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
8268         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
8269         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
8270         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
8271         return tag_ptr(ret_conv, true);
8272 }
8273
8274 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignerProvider_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
8275         void* this_arg_ptr = untag_ptr(this_arg);
8276         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8277         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
8278         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
8279         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8280         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8281         CVec_u8Z_free(ret_var);
8282         return ret_arr;
8283 }
8284
8285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignerProvider_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
8286         void* this_arg_ptr = untag_ptr(this_arg);
8287         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8288         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
8289         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
8290         int64_t ret_ref = 0;
8291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8292         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8293         return ret_ref;
8294 }
8295
8296 typedef struct LDKFeeEstimator_JCalls {
8297         atomic_size_t refcnt;
8298         JavaVM *vm;
8299         jweak o;
8300         jmethodID get_est_sat_per_1000_weight_meth;
8301 } LDKFeeEstimator_JCalls;
8302 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
8303         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
8304         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8305                 JNIEnv *env;
8306                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8307                 if (get_jenv_res == JNI_EDETACHED) {
8308                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8309                 } else {
8310                         DO_ASSERT(get_jenv_res == JNI_OK);
8311                 }
8312                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8313                 if (get_jenv_res == JNI_EDETACHED) {
8314                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8315                 }
8316                 FREE(j_calls);
8317         }
8318 }
8319 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
8320         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
8321         JNIEnv *env;
8322         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8323         if (get_jenv_res == JNI_EDETACHED) {
8324                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8325         } else {
8326                 DO_ASSERT(get_jenv_res == JNI_OK);
8327         }
8328         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
8329         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8330         CHECK(obj != NULL);
8331         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
8332         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8333                 (*env)->ExceptionDescribe(env);
8334                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
8335         }
8336         if (get_jenv_res == JNI_EDETACHED) {
8337                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8338         }
8339         return ret;
8340 }
8341 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
8342         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
8343         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8344 }
8345 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
8346         jclass c = (*env)->GetObjectClass(env, o);
8347         CHECK(c != NULL);
8348         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
8349         atomic_init(&calls->refcnt, 1);
8350         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8351         calls->o = (*env)->NewWeakGlobalRef(env, o);
8352         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
8353         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
8354
8355         LDKFeeEstimator ret = {
8356                 .this_arg = (void*) calls,
8357                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
8358                 .free = LDKFeeEstimator_JCalls_free,
8359         };
8360         return ret;
8361 }
8362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
8363         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
8364         *res_ptr = LDKFeeEstimator_init(env, clz, o);
8365         return tag_ptr(res_ptr, true);
8366 }
8367 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) {
8368         void* this_arg_ptr = untag_ptr(this_arg);
8369         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8370         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
8371         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
8372         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
8373         return ret_conv;
8374 }
8375
8376 typedef struct LDKRouter_JCalls {
8377         atomic_size_t refcnt;
8378         JavaVM *vm;
8379         jweak o;
8380         jmethodID find_route_meth;
8381         jmethodID find_route_with_id_meth;
8382 } LDKRouter_JCalls;
8383 static void LDKRouter_JCalls_free(void* this_arg) {
8384         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
8385         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8386                 JNIEnv *env;
8387                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8388                 if (get_jenv_res == JNI_EDETACHED) {
8389                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8390                 } else {
8391                         DO_ASSERT(get_jenv_res == JNI_OK);
8392                 }
8393                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8394                 if (get_jenv_res == JNI_EDETACHED) {
8395                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8396                 }
8397                 FREE(j_calls);
8398         }
8399 }
8400 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, LDKCVec_ChannelDetailsZ * first_hops, const LDKInFlightHtlcs * inflight_htlcs) {
8401         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
8402         JNIEnv *env;
8403         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8404         if (get_jenv_res == JNI_EDETACHED) {
8405                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8406         } else {
8407                 DO_ASSERT(get_jenv_res == JNI_OK);
8408         }
8409         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
8410         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
8411         LDKRouteParameters route_params_var = *route_params;
8412         int64_t route_params_ref = 0;
8413         route_params_var = RouteParameters_clone(&route_params_var);
8414         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
8415         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
8416         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
8417         int64_tArray first_hops_arr = NULL;
8418         if (first_hops != NULL) {
8419                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
8420                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
8421                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
8422                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
8423                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
8424                         int64_t first_hops_conv_16_ref = 0;
8425                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
8426                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
8427                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
8428                 }
8429                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
8430         }
8431         LDKInFlightHtlcs inflight_htlcs_var = *inflight_htlcs;
8432         int64_t inflight_htlcs_ref = 0;
8433         inflight_htlcs_var = InFlightHtlcs_clone(&inflight_htlcs_var);
8434         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
8435         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
8436         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8437         CHECK(obj != NULL);
8438         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, route_params_ref, first_hops_arr, inflight_htlcs_ref);
8439         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8440                 (*env)->ExceptionDescribe(env);
8441                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
8442         }
8443         void* ret_ptr = untag_ptr(ret);
8444         CHECK_ACCESS(ret_ptr);
8445         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
8446         FREE(untag_ptr(ret));
8447         if (get_jenv_res == JNI_EDETACHED) {
8448                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8449         }
8450         return ret_conv;
8451 }
8452 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) {
8453         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
8454         JNIEnv *env;
8455         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8456         if (get_jenv_res == JNI_EDETACHED) {
8457                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8458         } else {
8459                 DO_ASSERT(get_jenv_res == JNI_OK);
8460         }
8461         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
8462         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
8463         LDKRouteParameters route_params_var = *route_params;
8464         int64_t route_params_ref = 0;
8465         route_params_var = RouteParameters_clone(&route_params_var);
8466         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
8467         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
8468         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
8469         int64_tArray first_hops_arr = NULL;
8470         if (first_hops != NULL) {
8471                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
8472                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
8473                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
8474                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
8475                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
8476                         int64_t first_hops_conv_16_ref = 0;
8477                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
8478                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
8479                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
8480                 }
8481                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
8482         }
8483         LDKInFlightHtlcs inflight_htlcs_var = *inflight_htlcs;
8484         int64_t inflight_htlcs_ref = 0;
8485         inflight_htlcs_var = InFlightHtlcs_clone(&inflight_htlcs_var);
8486         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
8487         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
8488         int8_tArray _payment_hash_arr = (*env)->NewByteArray(env, 32);
8489         (*env)->SetByteArrayRegion(env, _payment_hash_arr, 0, 32, _payment_hash.data);
8490         int8_tArray _payment_id_arr = (*env)->NewByteArray(env, 32);
8491         (*env)->SetByteArrayRegion(env, _payment_id_arr, 0, 32, _payment_id.data);
8492         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8493         CHECK(obj != NULL);
8494         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);
8495         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8496                 (*env)->ExceptionDescribe(env);
8497                 (*env)->FatalError(env, "A call to find_route_with_id in LDKRouter from rust threw an exception.");
8498         }
8499         void* ret_ptr = untag_ptr(ret);
8500         CHECK_ACCESS(ret_ptr);
8501         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
8502         FREE(untag_ptr(ret));
8503         if (get_jenv_res == JNI_EDETACHED) {
8504                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8505         }
8506         return ret_conv;
8507 }
8508 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
8509         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
8510         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8511 }
8512 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
8513         jclass c = (*env)->GetObjectClass(env, o);
8514         CHECK(c != NULL);
8515         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
8516         atomic_init(&calls->refcnt, 1);
8517         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8518         calls->o = (*env)->NewWeakGlobalRef(env, o);
8519         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[JJ)J");
8520         CHECK(calls->find_route_meth != NULL);
8521         calls->find_route_with_id_meth = (*env)->GetMethodID(env, c, "find_route_with_id", "([BJ[JJ[B[B)J");
8522         CHECK(calls->find_route_with_id_meth != NULL);
8523
8524         LDKRouter ret = {
8525                 .this_arg = (void*) calls,
8526                 .find_route = find_route_LDKRouter_jcall,
8527                 .find_route_with_id = find_route_with_id_LDKRouter_jcall,
8528                 .free = LDKRouter_JCalls_free,
8529         };
8530         return ret;
8531 }
8532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
8533         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
8534         *res_ptr = LDKRouter_init(env, clz, o);
8535         return tag_ptr(res_ptr, true);
8536 }
8537 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) {
8538         void* this_arg_ptr = untag_ptr(this_arg);
8539         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8540         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
8541         LDKPublicKey payer_ref;
8542         CHECK((*env)->GetArrayLength(env, payer) == 33);
8543         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
8544         LDKRouteParameters route_params_conv;
8545         route_params_conv.inner = untag_ptr(route_params);
8546         route_params_conv.is_owned = ptr_is_owned(route_params);
8547         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
8548         route_params_conv.is_owned = false;
8549         LDKCVec_ChannelDetailsZ first_hops_constr;
8550         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
8551         if (first_hops != NULL) {
8552                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
8553                 if (first_hops_constr.datalen > 0)
8554                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
8555                 else
8556                         first_hops_constr.data = NULL;
8557                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
8558                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
8559                         int64_t first_hops_conv_16 = first_hops_vals[q];
8560                         LDKChannelDetails first_hops_conv_16_conv;
8561                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
8562                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
8563                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
8564                         first_hops_conv_16_conv.is_owned = false;
8565                         first_hops_constr.data[q] = first_hops_conv_16_conv;
8566                 }
8567                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
8568                 first_hops_ptr = &first_hops_constr;
8569         }
8570         LDKInFlightHtlcs inflight_htlcs_conv;
8571         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
8572         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
8573         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
8574         inflight_htlcs_conv.is_owned = false;
8575         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8576         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, first_hops_ptr, &inflight_htlcs_conv);
8577         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
8578         return tag_ptr(ret_conv, true);
8579 }
8580
8581 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) {
8582         void* this_arg_ptr = untag_ptr(this_arg);
8583         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8584         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
8585         LDKPublicKey payer_ref;
8586         CHECK((*env)->GetArrayLength(env, payer) == 33);
8587         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
8588         LDKRouteParameters route_params_conv;
8589         route_params_conv.inner = untag_ptr(route_params);
8590         route_params_conv.is_owned = ptr_is_owned(route_params);
8591         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
8592         route_params_conv.is_owned = false;
8593         LDKCVec_ChannelDetailsZ first_hops_constr;
8594         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
8595         if (first_hops != NULL) {
8596                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
8597                 if (first_hops_constr.datalen > 0)
8598                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
8599                 else
8600                         first_hops_constr.data = NULL;
8601                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
8602                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
8603                         int64_t first_hops_conv_16 = first_hops_vals[q];
8604                         LDKChannelDetails first_hops_conv_16_conv;
8605                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
8606                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
8607                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
8608                         first_hops_conv_16_conv.is_owned = false;
8609                         first_hops_constr.data[q] = first_hops_conv_16_conv;
8610                 }
8611                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
8612                 first_hops_ptr = &first_hops_constr;
8613         }
8614         LDKInFlightHtlcs inflight_htlcs_conv;
8615         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
8616         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
8617         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
8618         inflight_htlcs_conv.is_owned = false;
8619         LDKThirtyTwoBytes _payment_hash_ref;
8620         CHECK((*env)->GetArrayLength(env, _payment_hash) == 32);
8621         (*env)->GetByteArrayRegion(env, _payment_hash, 0, 32, _payment_hash_ref.data);
8622         LDKThirtyTwoBytes _payment_id_ref;
8623         CHECK((*env)->GetArrayLength(env, _payment_id) == 32);
8624         (*env)->GetByteArrayRegion(env, _payment_id, 0, 32, _payment_id_ref.data);
8625         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8626         *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);
8627         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
8628         return tag_ptr(ret_conv, true);
8629 }
8630
8631 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
8632         return ThirtyTwoBytes_clone(&owner->a);
8633 }
8634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8635         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
8636         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8637         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
8638         return ret_arr;
8639 }
8640
8641 static inline struct LDKChannelManager C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
8642         LDKChannelManager ret = owner->b;
8643         ret.is_owned = false;
8644         return ret;
8645 }
8646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8647         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
8648         LDKChannelManager ret_var = C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
8649         int64_t ret_ref = 0;
8650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8651         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8652         return ret_ref;
8653 }
8654
8655 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
8656 CHECK(owner->result_ok);
8657         return &*owner->contents.result;
8658 }
8659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8660         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
8661         int64_t ret_ret = tag_ptr(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv), false);
8662         return ret_ret;
8663 }
8664
8665 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
8666 CHECK(!owner->result_ok);
8667         return DecodeError_clone(&*owner->contents.err);
8668 }
8669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8670         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
8671         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8672         *ret_copy = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
8673         int64_t ret_ref = tag_ptr(ret_copy, true);
8674         return ret_ref;
8675 }
8676
8677 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
8678         LDKChannelConfig ret = *owner->contents.result;
8679         ret.is_owned = false;
8680         return ret;
8681 }
8682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8683         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
8684         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
8685         int64_t ret_ref = 0;
8686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8687         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8688         return ret_ref;
8689 }
8690
8691 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
8692 CHECK(!owner->result_ok);
8693         return DecodeError_clone(&*owner->contents.err);
8694 }
8695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8696         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
8697         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8698         *ret_copy = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
8699         int64_t ret_ref = tag_ptr(ret_copy, true);
8700         return ret_ref;
8701 }
8702
8703 static jclass LDKCOption_APIErrorZ_Some_class = NULL;
8704 static jmethodID LDKCOption_APIErrorZ_Some_meth = NULL;
8705 static jclass LDKCOption_APIErrorZ_None_class = NULL;
8706 static jmethodID LDKCOption_APIErrorZ_None_meth = NULL;
8707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1APIErrorZ_init (JNIEnv *env, jclass clz) {
8708         LDKCOption_APIErrorZ_Some_class =
8709                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_APIErrorZ$Some"));
8710         CHECK(LDKCOption_APIErrorZ_Some_class != NULL);
8711         LDKCOption_APIErrorZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_APIErrorZ_Some_class, "<init>", "(J)V");
8712         CHECK(LDKCOption_APIErrorZ_Some_meth != NULL);
8713         LDKCOption_APIErrorZ_None_class =
8714                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_APIErrorZ$None"));
8715         CHECK(LDKCOption_APIErrorZ_None_class != NULL);
8716         LDKCOption_APIErrorZ_None_meth = (*env)->GetMethodID(env, LDKCOption_APIErrorZ_None_class, "<init>", "()V");
8717         CHECK(LDKCOption_APIErrorZ_None_meth != NULL);
8718 }
8719 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1APIErrorZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8720         LDKCOption_APIErrorZ *obj = (LDKCOption_APIErrorZ*)untag_ptr(ptr);
8721         switch(obj->tag) {
8722                 case LDKCOption_APIErrorZ_Some: {
8723                         int64_t some_ref = tag_ptr(&obj->some, false);
8724                         return (*env)->NewObject(env, LDKCOption_APIErrorZ_Some_class, LDKCOption_APIErrorZ_Some_meth, some_ref);
8725                 }
8726                 case LDKCOption_APIErrorZ_None: {
8727                         return (*env)->NewObject(env, LDKCOption_APIErrorZ_None_class, LDKCOption_APIErrorZ_None_meth);
8728                 }
8729                 default: abort();
8730         }
8731 }
8732 static inline struct LDKCOption_APIErrorZ CResult_COption_APIErrorZDecodeErrorZ_get_ok(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR owner){
8733 CHECK(owner->result_ok);
8734         return COption_APIErrorZ_clone(&*owner->contents.result);
8735 }
8736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8737         LDKCResult_COption_APIErrorZDecodeErrorZ* owner_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(owner);
8738         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
8739         *ret_copy = CResult_COption_APIErrorZDecodeErrorZ_get_ok(owner_conv);
8740         int64_t ret_ref = tag_ptr(ret_copy, true);
8741         return ret_ref;
8742 }
8743
8744 static inline struct LDKDecodeError CResult_COption_APIErrorZDecodeErrorZ_get_err(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR owner){
8745 CHECK(!owner->result_ok);
8746         return DecodeError_clone(&*owner->contents.err);
8747 }
8748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8749         LDKCResult_COption_APIErrorZDecodeErrorZ* owner_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(owner);
8750         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8751         *ret_copy = CResult_COption_APIErrorZDecodeErrorZ_get_err(owner_conv);
8752         int64_t ret_ref = tag_ptr(ret_copy, true);
8753         return ret_ref;
8754 }
8755
8756 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
8757         LDKOutPoint ret = *owner->contents.result;
8758         ret.is_owned = false;
8759         return ret;
8760 }
8761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8762         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
8763         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
8764         int64_t ret_ref = 0;
8765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8766         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8767         return ret_ref;
8768 }
8769
8770 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
8771 CHECK(!owner->result_ok);
8772         return DecodeError_clone(&*owner->contents.err);
8773 }
8774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8775         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
8776         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8777         *ret_copy = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
8778         int64_t ret_ref = tag_ptr(ret_copy, true);
8779         return ret_ref;
8780 }
8781
8782 typedef struct LDKType_JCalls {
8783         atomic_size_t refcnt;
8784         JavaVM *vm;
8785         jweak o;
8786         jmethodID type_id_meth;
8787         jmethodID debug_str_meth;
8788         jmethodID write_meth;
8789 } LDKType_JCalls;
8790 static void LDKType_JCalls_free(void* this_arg) {
8791         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
8792         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8793                 JNIEnv *env;
8794                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8795                 if (get_jenv_res == JNI_EDETACHED) {
8796                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8797                 } else {
8798                         DO_ASSERT(get_jenv_res == JNI_OK);
8799                 }
8800                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8801                 if (get_jenv_res == JNI_EDETACHED) {
8802                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8803                 }
8804                 FREE(j_calls);
8805         }
8806 }
8807 uint16_t type_id_LDKType_jcall(const void* this_arg) {
8808         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
8809         JNIEnv *env;
8810         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8811         if (get_jenv_res == JNI_EDETACHED) {
8812                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8813         } else {
8814                 DO_ASSERT(get_jenv_res == JNI_OK);
8815         }
8816         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8817         CHECK(obj != NULL);
8818         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
8819         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8820                 (*env)->ExceptionDescribe(env);
8821                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
8822         }
8823         if (get_jenv_res == JNI_EDETACHED) {
8824                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8825         }
8826         return ret;
8827 }
8828 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
8829         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
8830         JNIEnv *env;
8831         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8832         if (get_jenv_res == JNI_EDETACHED) {
8833                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8834         } else {
8835                 DO_ASSERT(get_jenv_res == JNI_OK);
8836         }
8837         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8838         CHECK(obj != NULL);
8839         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
8840         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8841                 (*env)->ExceptionDescribe(env);
8842                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
8843         }
8844         LDKStr ret_conv = java_to_owned_str(env, ret);
8845         if (get_jenv_res == JNI_EDETACHED) {
8846                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8847         }
8848         return ret_conv;
8849 }
8850 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
8851         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
8852         JNIEnv *env;
8853         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8854         if (get_jenv_res == JNI_EDETACHED) {
8855                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8856         } else {
8857                 DO_ASSERT(get_jenv_res == JNI_OK);
8858         }
8859         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8860         CHECK(obj != NULL);
8861         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
8862         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8863                 (*env)->ExceptionDescribe(env);
8864                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
8865         }
8866         LDKCVec_u8Z ret_ref;
8867         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
8868         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8869         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
8870         if (get_jenv_res == JNI_EDETACHED) {
8871                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8872         }
8873         return ret_ref;
8874 }
8875 static void LDKType_JCalls_cloned(LDKType* new_obj) {
8876         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
8877         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8878 }
8879 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
8880         jclass c = (*env)->GetObjectClass(env, o);
8881         CHECK(c != NULL);
8882         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
8883         atomic_init(&calls->refcnt, 1);
8884         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8885         calls->o = (*env)->NewWeakGlobalRef(env, o);
8886         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
8887         CHECK(calls->type_id_meth != NULL);
8888         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
8889         CHECK(calls->debug_str_meth != NULL);
8890         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
8891         CHECK(calls->write_meth != NULL);
8892
8893         LDKType ret = {
8894                 .this_arg = (void*) calls,
8895                 .type_id = type_id_LDKType_jcall,
8896                 .debug_str = debug_str_LDKType_jcall,
8897                 .write = write_LDKType_jcall,
8898                 .cloned = LDKType_JCalls_cloned,
8899                 .free = LDKType_JCalls_free,
8900         };
8901         return ret;
8902 }
8903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
8904         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
8905         *res_ptr = LDKType_init(env, clz, o);
8906         return tag_ptr(res_ptr, true);
8907 }
8908 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
8909         void* this_arg_ptr = untag_ptr(this_arg);
8910         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8911         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
8912         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
8913         return ret_conv;
8914 }
8915
8916 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
8917         void* this_arg_ptr = untag_ptr(this_arg);
8918         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8919         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
8920         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
8921         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8922         Str_free(ret_str);
8923         return ret_conv;
8924 }
8925
8926 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
8927         void* this_arg_ptr = untag_ptr(this_arg);
8928         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8929         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
8930         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8931         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8932         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8933         CVec_u8Z_free(ret_var);
8934         return ret_arr;
8935 }
8936
8937 static jclass LDKCOption_TypeZ_Some_class = NULL;
8938 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
8939 static jclass LDKCOption_TypeZ_None_class = NULL;
8940 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
8941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
8942         LDKCOption_TypeZ_Some_class =
8943                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
8944         CHECK(LDKCOption_TypeZ_Some_class != NULL);
8945         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
8946         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
8947         LDKCOption_TypeZ_None_class =
8948                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
8949         CHECK(LDKCOption_TypeZ_None_class != NULL);
8950         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
8951         CHECK(LDKCOption_TypeZ_None_meth != NULL);
8952 }
8953 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8954         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)untag_ptr(ptr);
8955         switch(obj->tag) {
8956                 case LDKCOption_TypeZ_Some: {
8957                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
8958                         *some_ret = Type_clone(&obj->some);
8959                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, tag_ptr(some_ret, true));
8960                 }
8961                 case LDKCOption_TypeZ_None: {
8962                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
8963                 }
8964                 default: abort();
8965         }
8966 }
8967 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
8968 CHECK(owner->result_ok);
8969         return COption_TypeZ_clone(&*owner->contents.result);
8970 }
8971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8972         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
8973         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
8974         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
8975         int64_t ret_ref = tag_ptr(ret_copy, true);
8976         return ret_ref;
8977 }
8978
8979 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
8980 CHECK(!owner->result_ok);
8981         return DecodeError_clone(&*owner->contents.err);
8982 }
8983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8984         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
8985         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8986         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
8987         int64_t ret_ref = tag_ptr(ret_copy, true);
8988         return ret_ref;
8989 }
8990
8991 static jclass LDKPaymentError_Invoice_class = NULL;
8992 static jmethodID LDKPaymentError_Invoice_meth = NULL;
8993 static jclass LDKPaymentError_Sending_class = NULL;
8994 static jmethodID LDKPaymentError_Sending_meth = NULL;
8995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
8996         LDKPaymentError_Invoice_class =
8997                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
8998         CHECK(LDKPaymentError_Invoice_class != NULL);
8999         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
9000         CHECK(LDKPaymentError_Invoice_meth != NULL);
9001         LDKPaymentError_Sending_class =
9002                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
9003         CHECK(LDKPaymentError_Sending_class != NULL);
9004         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(Lorg/ldk/enums/RetryableSendFailure;)V");
9005         CHECK(LDKPaymentError_Sending_meth != NULL);
9006 }
9007 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9008         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
9009         switch(obj->tag) {
9010                 case LDKPaymentError_Invoice: {
9011                         LDKStr invoice_str = obj->invoice;
9012                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
9013                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
9014                 }
9015                 case LDKPaymentError_Sending: {
9016                         jclass sending_conv = LDKRetryableSendFailure_to_java(env, obj->sending);
9017                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_conv);
9018                 }
9019                 default: abort();
9020         }
9021 }
9022 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
9023 CHECK(owner->result_ok);
9024         return ThirtyTwoBytes_clone(&*owner->contents.result);
9025 }
9026 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9027         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
9028         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
9029         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
9030         return ret_arr;
9031 }
9032
9033 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
9034 CHECK(!owner->result_ok);
9035         return PaymentError_clone(&*owner->contents.err);
9036 }
9037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9038         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
9039         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
9040         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
9041         int64_t ret_ref = tag_ptr(ret_copy, true);
9042         return ret_ref;
9043 }
9044
9045 static inline void CResult_NonePaymentErrorZ_get_ok(LDKCResult_NonePaymentErrorZ *NONNULL_PTR owner){
9046 CHECK(owner->result_ok);
9047         return *owner->contents.result;
9048 }
9049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9050         LDKCResult_NonePaymentErrorZ* owner_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(owner);
9051         CResult_NonePaymentErrorZ_get_ok(owner_conv);
9052 }
9053
9054 static inline struct LDKPaymentError CResult_NonePaymentErrorZ_get_err(LDKCResult_NonePaymentErrorZ *NONNULL_PTR owner){
9055 CHECK(!owner->result_ok);
9056         return PaymentError_clone(&*owner->contents.err);
9057 }
9058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9059         LDKCResult_NonePaymentErrorZ* owner_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(owner);
9060         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
9061         *ret_copy = CResult_NonePaymentErrorZ_get_err(owner_conv);
9062         int64_t ret_ref = tag_ptr(ret_copy, true);
9063         return ret_ref;
9064 }
9065
9066 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
9067 CHECK(owner->result_ok);
9068         return *owner->contents.result;
9069 }
9070 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9071         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
9072         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
9073         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
9074         return ret_conv;
9075 }
9076
9077 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
9078 CHECK(!owner->result_ok);
9079         return *owner->contents.err;
9080 }
9081 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9082         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
9083         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
9084         return ret_conv;
9085 }
9086
9087 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
9088 CHECK(owner->result_ok);
9089         return *owner->contents.result;
9090 }
9091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9092         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
9093         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
9094         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
9095         return ret_arr;
9096 }
9097
9098 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
9099 CHECK(!owner->result_ok);
9100         return *owner->contents.err;
9101 }
9102 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9103         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
9104         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
9105         return ret_conv;
9106 }
9107
9108 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
9109         LDKChannelMonitorUpdate ret = *owner->contents.result;
9110         ret.is_owned = false;
9111         return ret;
9112 }
9113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9114         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
9115         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
9116         int64_t ret_ref = 0;
9117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9118         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9119         return ret_ref;
9120 }
9121
9122 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
9123 CHECK(!owner->result_ok);
9124         return DecodeError_clone(&*owner->contents.err);
9125 }
9126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9127         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
9128         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9129         *ret_copy = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
9130         int64_t ret_ref = tag_ptr(ret_copy, true);
9131         return ret_ref;
9132 }
9133
9134 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
9135 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
9136 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
9137 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
9138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
9139         LDKCOption_MonitorEventZ_Some_class =
9140                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
9141         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
9142         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
9143         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
9144         LDKCOption_MonitorEventZ_None_class =
9145                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
9146         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
9147         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
9148         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
9149 }
9150 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9151         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)untag_ptr(ptr);
9152         switch(obj->tag) {
9153                 case LDKCOption_MonitorEventZ_Some: {
9154                         int64_t some_ref = tag_ptr(&obj->some, false);
9155                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
9156                 }
9157                 case LDKCOption_MonitorEventZ_None: {
9158                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
9159                 }
9160                 default: abort();
9161         }
9162 }
9163 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
9164 CHECK(owner->result_ok);
9165         return COption_MonitorEventZ_clone(&*owner->contents.result);
9166 }
9167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9168         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
9169         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
9170         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
9171         int64_t ret_ref = tag_ptr(ret_copy, true);
9172         return ret_ref;
9173 }
9174
9175 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
9176 CHECK(!owner->result_ok);
9177         return DecodeError_clone(&*owner->contents.err);
9178 }
9179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9180         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
9181         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9182         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
9183         int64_t ret_ref = tag_ptr(ret_copy, true);
9184         return ret_ref;
9185 }
9186
9187 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
9188         LDKHTLCUpdate ret = *owner->contents.result;
9189         ret.is_owned = false;
9190         return ret;
9191 }
9192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9193         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
9194         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
9195         int64_t ret_ref = 0;
9196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9197         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9198         return ret_ref;
9199 }
9200
9201 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
9202 CHECK(!owner->result_ok);
9203         return DecodeError_clone(&*owner->contents.err);
9204 }
9205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9206         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
9207         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9208         *ret_copy = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
9209         int64_t ret_ref = tag_ptr(ret_copy, true);
9210         return ret_ref;
9211 }
9212
9213 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
9214         LDKOutPoint ret = owner->a;
9215         ret.is_owned = false;
9216         return ret;
9217 }
9218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9219         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
9220         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
9221         int64_t ret_ref = 0;
9222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9223         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9224         return ret_ref;
9225 }
9226
9227 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
9228         return CVec_u8Z_clone(&owner->b);
9229 }
9230 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9231         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
9232         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
9233         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9234         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9235         CVec_u8Z_free(ret_var);
9236         return ret_arr;
9237 }
9238
9239 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
9240         return owner->a;
9241 }
9242 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9243         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
9244         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
9245         return ret_conv;
9246 }
9247
9248 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
9249         return CVec_u8Z_clone(&owner->b);
9250 }
9251 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9252         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
9253         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
9254         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9255         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9256         CVec_u8Z_free(ret_var);
9257         return ret_arr;
9258 }
9259
9260 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
9261         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
9262         for (size_t i = 0; i < ret.datalen; i++) {
9263                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
9264         }
9265         return ret;
9266 }
9267 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
9268         return ThirtyTwoBytes_clone(&owner->a);
9269 }
9270 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9271         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
9272         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
9273         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
9274         return ret_arr;
9275 }
9276
9277 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
9278         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
9279 }
9280 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9281         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
9282         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
9283         int64_tArray ret_arr = NULL;
9284         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9285         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9286         for (size_t v = 0; v < ret_var.datalen; v++) {
9287                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
9288                 *ret_conv_21_conv = ret_var.data[v];
9289                 ret_arr_ptr[v] = tag_ptr(ret_conv_21_conv, true);
9290         }
9291         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9292         FREE(ret_var.data);
9293         return ret_arr;
9294 }
9295
9296 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
9297         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 };
9298         for (size_t i = 0; i < ret.datalen; i++) {
9299                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
9300         }
9301         return ret;
9302 }
9303 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
9304         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
9305         for (size_t i = 0; i < ret.datalen; i++) {
9306                 ret.data[i] = Event_clone(&orig->data[i]);
9307         }
9308         return ret;
9309 }
9310 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
9311         return owner->a;
9312 }
9313 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9314         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
9315         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
9316         return ret_conv;
9317 }
9318
9319 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
9320         return TxOut_clone(&owner->b);
9321 }
9322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9323         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
9324         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
9325         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
9326         return tag_ptr(ret_ref, true);
9327 }
9328
9329 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
9330         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
9331         for (size_t i = 0; i < ret.datalen; i++) {
9332                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
9333         }
9334         return ret;
9335 }
9336 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
9337         return ThirtyTwoBytes_clone(&owner->a);
9338 }
9339 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9340         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
9341         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
9342         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
9343         return ret_arr;
9344 }
9345
9346 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
9347         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
9348 }
9349 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9350         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
9351         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
9352         int64_tArray ret_arr = NULL;
9353         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9354         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9355         for (size_t u = 0; u < ret_var.datalen; u++) {
9356                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
9357                 *ret_conv_20_conv = ret_var.data[u];
9358                 ret_arr_ptr[u] = tag_ptr(ret_conv_20_conv, true);
9359         }
9360         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9361         FREE(ret_var.data);
9362         return ret_arr;
9363 }
9364
9365 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
9366         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 };
9367         for (size_t i = 0; i < ret.datalen; i++) {
9368                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
9369         }
9370         return ret;
9371 }
9372 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
9373 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
9374 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
9375 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
9376 static jclass LDKBalance_ContentiousClaimable_class = NULL;
9377 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
9378 static jclass LDKBalance_MaybeTimeoutClaimableHTLC_class = NULL;
9379 static jmethodID LDKBalance_MaybeTimeoutClaimableHTLC_meth = NULL;
9380 static jclass LDKBalance_MaybePreimageClaimableHTLC_class = NULL;
9381 static jmethodID LDKBalance_MaybePreimageClaimableHTLC_meth = NULL;
9382 static jclass LDKBalance_CounterpartyRevokedOutputClaimable_class = NULL;
9383 static jmethodID LDKBalance_CounterpartyRevokedOutputClaimable_meth = NULL;
9384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
9385         LDKBalance_ClaimableOnChannelClose_class =
9386                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
9387         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
9388         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
9389         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
9390         LDKBalance_ClaimableAwaitingConfirmations_class =
9391                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
9392         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
9393         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
9394         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
9395         LDKBalance_ContentiousClaimable_class =
9396                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
9397         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
9398         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
9399         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
9400         LDKBalance_MaybeTimeoutClaimableHTLC_class =
9401                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeTimeoutClaimableHTLC"));
9402         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_class != NULL);
9403         LDKBalance_MaybeTimeoutClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, "<init>", "(JI)V");
9404         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_meth != NULL);
9405         LDKBalance_MaybePreimageClaimableHTLC_class =
9406                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybePreimageClaimableHTLC"));
9407         CHECK(LDKBalance_MaybePreimageClaimableHTLC_class != NULL);
9408         LDKBalance_MaybePreimageClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybePreimageClaimableHTLC_class, "<init>", "(JI)V");
9409         CHECK(LDKBalance_MaybePreimageClaimableHTLC_meth != NULL);
9410         LDKBalance_CounterpartyRevokedOutputClaimable_class =
9411                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$CounterpartyRevokedOutputClaimable"));
9412         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_class != NULL);
9413         LDKBalance_CounterpartyRevokedOutputClaimable_meth = (*env)->GetMethodID(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, "<init>", "(J)V");
9414         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_meth != NULL);
9415 }
9416 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9417         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
9418         switch(obj->tag) {
9419                 case LDKBalance_ClaimableOnChannelClose: {
9420                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
9421                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
9422                 }
9423                 case LDKBalance_ClaimableAwaitingConfirmations: {
9424                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
9425                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
9426                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
9427                 }
9428                 case LDKBalance_ContentiousClaimable: {
9429                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
9430                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
9431                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
9432                 }
9433                 case LDKBalance_MaybeTimeoutClaimableHTLC: {
9434                         int64_t claimable_amount_satoshis_conv = obj->maybe_timeout_claimable_htlc.claimable_amount_satoshis;
9435                         int32_t claimable_height_conv = obj->maybe_timeout_claimable_htlc.claimable_height;
9436                         return (*env)->NewObject(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, LDKBalance_MaybeTimeoutClaimableHTLC_meth, claimable_amount_satoshis_conv, claimable_height_conv);
9437                 }
9438                 case LDKBalance_MaybePreimageClaimableHTLC: {
9439                         int64_t claimable_amount_satoshis_conv = obj->maybe_preimage_claimable_htlc.claimable_amount_satoshis;
9440                         int32_t expiry_height_conv = obj->maybe_preimage_claimable_htlc.expiry_height;
9441                         return (*env)->NewObject(env, LDKBalance_MaybePreimageClaimableHTLC_class, LDKBalance_MaybePreimageClaimableHTLC_meth, claimable_amount_satoshis_conv, expiry_height_conv);
9442                 }
9443                 case LDKBalance_CounterpartyRevokedOutputClaimable: {
9444                         int64_t claimable_amount_satoshis_conv = obj->counterparty_revoked_output_claimable.claimable_amount_satoshis;
9445                         return (*env)->NewObject(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, LDKBalance_CounterpartyRevokedOutputClaimable_meth, claimable_amount_satoshis_conv);
9446                 }
9447                 default: abort();
9448         }
9449 }
9450 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
9451         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
9452         for (size_t i = 0; i < ret.datalen; i++) {
9453                 ret.data[i] = Balance_clone(&orig->data[i]);
9454         }
9455         return ret;
9456 }
9457 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
9458 CHECK(owner->result_ok);
9459         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
9460 }
9461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9462         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
9463         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
9464         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
9465         return tag_ptr(ret_conv, true);
9466 }
9467
9468 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
9469 CHECK(!owner->result_ok);
9470         return DecodeError_clone(&*owner->contents.err);
9471 }
9472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9473         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
9474         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9475         *ret_copy = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
9476         int64_t ret_ref = tag_ptr(ret_copy, true);
9477         return ret_ref;
9478 }
9479
9480 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
9481         return owner->a;
9482 }
9483 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9484         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
9485         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
9486         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
9487         return ret_arr;
9488 }
9489
9490 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
9491         return Type_clone(&owner->b);
9492 }
9493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9494         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
9495         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
9496         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
9497         return tag_ptr(ret_ret, true);
9498 }
9499
9500 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
9501         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
9502         for (size_t i = 0; i < ret.datalen; i++) {
9503                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
9504         }
9505         return ret;
9506 }
9507 typedef struct LDKCustomOnionMessageContents_JCalls {
9508         atomic_size_t refcnt;
9509         JavaVM *vm;
9510         jweak o;
9511         jmethodID tlv_type_meth;
9512         jmethodID write_meth;
9513 } LDKCustomOnionMessageContents_JCalls;
9514 static void LDKCustomOnionMessageContents_JCalls_free(void* this_arg) {
9515         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
9516         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9517                 JNIEnv *env;
9518                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9519                 if (get_jenv_res == JNI_EDETACHED) {
9520                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9521                 } else {
9522                         DO_ASSERT(get_jenv_res == JNI_OK);
9523                 }
9524                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9525                 if (get_jenv_res == JNI_EDETACHED) {
9526                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9527                 }
9528                 FREE(j_calls);
9529         }
9530 }
9531 uint64_t tlv_type_LDKCustomOnionMessageContents_jcall(const void* this_arg) {
9532         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
9533         JNIEnv *env;
9534         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9535         if (get_jenv_res == JNI_EDETACHED) {
9536                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9537         } else {
9538                 DO_ASSERT(get_jenv_res == JNI_OK);
9539         }
9540         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9541         CHECK(obj != NULL);
9542         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->tlv_type_meth);
9543         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9544                 (*env)->ExceptionDescribe(env);
9545                 (*env)->FatalError(env, "A call to tlv_type in LDKCustomOnionMessageContents from rust threw an exception.");
9546         }
9547         if (get_jenv_res == JNI_EDETACHED) {
9548                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9549         }
9550         return ret;
9551 }
9552 LDKCVec_u8Z write_LDKCustomOnionMessageContents_jcall(const void* this_arg) {
9553         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
9554         JNIEnv *env;
9555         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9556         if (get_jenv_res == JNI_EDETACHED) {
9557                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9558         } else {
9559                 DO_ASSERT(get_jenv_res == JNI_OK);
9560         }
9561         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9562         CHECK(obj != NULL);
9563         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
9564         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9565                 (*env)->ExceptionDescribe(env);
9566                 (*env)->FatalError(env, "A call to write in LDKCustomOnionMessageContents from rust threw an exception.");
9567         }
9568         LDKCVec_u8Z ret_ref;
9569         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
9570         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
9571         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
9572         if (get_jenv_res == JNI_EDETACHED) {
9573                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9574         }
9575         return ret_ref;
9576 }
9577 static void LDKCustomOnionMessageContents_JCalls_cloned(LDKCustomOnionMessageContents* new_obj) {
9578         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) new_obj->this_arg;
9579         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9580 }
9581 static inline LDKCustomOnionMessageContents LDKCustomOnionMessageContents_init (JNIEnv *env, jclass clz, jobject o) {
9582         jclass c = (*env)->GetObjectClass(env, o);
9583         CHECK(c != NULL);
9584         LDKCustomOnionMessageContents_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageContents_JCalls), "LDKCustomOnionMessageContents_JCalls");
9585         atomic_init(&calls->refcnt, 1);
9586         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9587         calls->o = (*env)->NewWeakGlobalRef(env, o);
9588         calls->tlv_type_meth = (*env)->GetMethodID(env, c, "tlv_type", "()J");
9589         CHECK(calls->tlv_type_meth != NULL);
9590         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
9591         CHECK(calls->write_meth != NULL);
9592
9593         LDKCustomOnionMessageContents ret = {
9594                 .this_arg = (void*) calls,
9595                 .tlv_type = tlv_type_LDKCustomOnionMessageContents_jcall,
9596                 .write = write_LDKCustomOnionMessageContents_jcall,
9597                 .cloned = LDKCustomOnionMessageContents_JCalls_cloned,
9598                 .free = LDKCustomOnionMessageContents_JCalls_free,
9599         };
9600         return ret;
9601 }
9602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomOnionMessageContents_1new(JNIEnv *env, jclass clz, jobject o) {
9603         LDKCustomOnionMessageContents *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
9604         *res_ptr = LDKCustomOnionMessageContents_init(env, clz, o);
9605         return tag_ptr(res_ptr, true);
9606 }
9607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1tlv_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
9608         void* this_arg_ptr = untag_ptr(this_arg);
9609         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9610         LDKCustomOnionMessageContents* this_arg_conv = (LDKCustomOnionMessageContents*)this_arg_ptr;
9611         int64_t ret_conv = (this_arg_conv->tlv_type)(this_arg_conv->this_arg);
9612         return ret_conv;
9613 }
9614
9615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
9616         void* this_arg_ptr = untag_ptr(this_arg);
9617         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9618         LDKCustomOnionMessageContents* this_arg_conv = (LDKCustomOnionMessageContents*)this_arg_ptr;
9619         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
9620         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9621         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9622         CVec_u8Z_free(ret_var);
9623         return ret_arr;
9624 }
9625
9626 static jclass LDKCOption_CustomOnionMessageContentsZ_Some_class = NULL;
9627 static jmethodID LDKCOption_CustomOnionMessageContentsZ_Some_meth = NULL;
9628 static jclass LDKCOption_CustomOnionMessageContentsZ_None_class = NULL;
9629 static jmethodID LDKCOption_CustomOnionMessageContentsZ_None_meth = NULL;
9630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CustomOnionMessageContentsZ_init (JNIEnv *env, jclass clz) {
9631         LDKCOption_CustomOnionMessageContentsZ_Some_class =
9632                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CustomOnionMessageContentsZ$Some"));
9633         CHECK(LDKCOption_CustomOnionMessageContentsZ_Some_class != NULL);
9634         LDKCOption_CustomOnionMessageContentsZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CustomOnionMessageContentsZ_Some_class, "<init>", "(J)V");
9635         CHECK(LDKCOption_CustomOnionMessageContentsZ_Some_meth != NULL);
9636         LDKCOption_CustomOnionMessageContentsZ_None_class =
9637                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CustomOnionMessageContentsZ$None"));
9638         CHECK(LDKCOption_CustomOnionMessageContentsZ_None_class != NULL);
9639         LDKCOption_CustomOnionMessageContentsZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CustomOnionMessageContentsZ_None_class, "<init>", "()V");
9640         CHECK(LDKCOption_CustomOnionMessageContentsZ_None_meth != NULL);
9641 }
9642 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CustomOnionMessageContentsZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9643         LDKCOption_CustomOnionMessageContentsZ *obj = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(ptr);
9644         switch(obj->tag) {
9645                 case LDKCOption_CustomOnionMessageContentsZ_Some: {
9646                         LDKCustomOnionMessageContents* some_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
9647                         *some_ret = CustomOnionMessageContents_clone(&obj->some);
9648                         return (*env)->NewObject(env, LDKCOption_CustomOnionMessageContentsZ_Some_class, LDKCOption_CustomOnionMessageContentsZ_Some_meth, tag_ptr(some_ret, true));
9649                 }
9650                 case LDKCOption_CustomOnionMessageContentsZ_None: {
9651                         return (*env)->NewObject(env, LDKCOption_CustomOnionMessageContentsZ_None_class, LDKCOption_CustomOnionMessageContentsZ_None_meth);
9652                 }
9653                 default: abort();
9654         }
9655 }
9656 static inline struct LDKCOption_CustomOnionMessageContentsZ CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_ok(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
9657 CHECK(owner->result_ok);
9658         return COption_CustomOnionMessageContentsZ_clone(&*owner->contents.result);
9659 }
9660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9661         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
9662         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
9663         *ret_copy = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_ok(owner_conv);
9664         int64_t ret_ref = tag_ptr(ret_copy, true);
9665         return ret_ref;
9666 }
9667
9668 static inline struct LDKDecodeError CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_err(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
9669 CHECK(!owner->result_ok);
9670         return DecodeError_clone(&*owner->contents.err);
9671 }
9672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9673         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
9674         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9675         *ret_copy = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_err(owner_conv);
9676         int64_t ret_ref = tag_ptr(ret_copy, true);
9677         return ret_ref;
9678 }
9679
9680 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
9681 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
9682 static jclass LDKCOption_NetAddressZ_None_class = NULL;
9683 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
9684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
9685         LDKCOption_NetAddressZ_Some_class =
9686                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
9687         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
9688         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
9689         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
9690         LDKCOption_NetAddressZ_None_class =
9691                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
9692         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
9693         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
9694         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
9695 }
9696 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9697         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)untag_ptr(ptr);
9698         switch(obj->tag) {
9699                 case LDKCOption_NetAddressZ_Some: {
9700                         int64_t some_ref = tag_ptr(&obj->some, false);
9701                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
9702                 }
9703                 case LDKCOption_NetAddressZ_None: {
9704                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
9705                 }
9706                 default: abort();
9707         }
9708 }
9709 static inline struct LDKPublicKey C2Tuple_PublicKeyCOption_NetAddressZZ_get_a(LDKC2Tuple_PublicKeyCOption_NetAddressZZ *NONNULL_PTR owner){
9710         return owner->a;
9711 }
9712 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9713         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* owner_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(owner);
9714         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
9715         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyCOption_NetAddressZZ_get_a(owner_conv).compressed_form);
9716         return ret_arr;
9717 }
9718
9719 static inline struct LDKCOption_NetAddressZ C2Tuple_PublicKeyCOption_NetAddressZZ_get_b(LDKC2Tuple_PublicKeyCOption_NetAddressZZ *NONNULL_PTR owner){
9720         return COption_NetAddressZ_clone(&owner->b);
9721 }
9722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9723         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* owner_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(owner);
9724         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
9725         *ret_copy = C2Tuple_PublicKeyCOption_NetAddressZZ_get_b(owner_conv);
9726         int64_t ret_ref = tag_ptr(ret_copy, true);
9727         return ret_ref;
9728 }
9729
9730 static inline LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_clone(const LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ *orig) {
9731         LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ clone bytes"), .datalen = orig->datalen };
9732         for (size_t i = 0; i < ret.datalen; i++) {
9733                 ret.data[i] = C2Tuple_PublicKeyCOption_NetAddressZZ_clone(&orig->data[i]);
9734         }
9735         return ret;
9736 }
9737 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
9738 CHECK(owner->result_ok);
9739         return CVec_u8Z_clone(&*owner->contents.result);
9740 }
9741 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9742         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
9743         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
9744         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9745         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9746         CVec_u8Z_free(ret_var);
9747         return ret_arr;
9748 }
9749
9750 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
9751         LDKPeerHandleError ret = *owner->contents.err;
9752         ret.is_owned = false;
9753         return ret;
9754 }
9755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9756         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
9757         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
9758         int64_t ret_ref = 0;
9759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9760         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9761         return ret_ref;
9762 }
9763
9764 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
9765 CHECK(owner->result_ok);
9766         return *owner->contents.result;
9767 }
9768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9769         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
9770         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
9771 }
9772
9773 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
9774         LDKPeerHandleError ret = *owner->contents.err;
9775         ret.is_owned = false;
9776         return ret;
9777 }
9778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9779         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
9780         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
9781         int64_t ret_ref = 0;
9782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9783         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9784         return ret_ref;
9785 }
9786
9787 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
9788 CHECK(owner->result_ok);
9789         return *owner->contents.result;
9790 }
9791 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9792         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
9793         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
9794         return ret_conv;
9795 }
9796
9797 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
9798         LDKPeerHandleError ret = *owner->contents.err;
9799         ret.is_owned = false;
9800         return ret;
9801 }
9802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9803         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
9804         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
9805         int64_t ret_ref = 0;
9806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9807         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9808         return ret_ref;
9809 }
9810
9811 static jclass LDKSendError_Secp256k1_class = NULL;
9812 static jmethodID LDKSendError_Secp256k1_meth = NULL;
9813 static jclass LDKSendError_TooBigPacket_class = NULL;
9814 static jmethodID LDKSendError_TooBigPacket_meth = NULL;
9815 static jclass LDKSendError_TooFewBlindedHops_class = NULL;
9816 static jmethodID LDKSendError_TooFewBlindedHops_meth = NULL;
9817 static jclass LDKSendError_InvalidFirstHop_class = NULL;
9818 static jmethodID LDKSendError_InvalidFirstHop_meth = NULL;
9819 static jclass LDKSendError_InvalidMessage_class = NULL;
9820 static jmethodID LDKSendError_InvalidMessage_meth = NULL;
9821 static jclass LDKSendError_BufferFull_class = NULL;
9822 static jmethodID LDKSendError_BufferFull_meth = NULL;
9823 static jclass LDKSendError_GetNodeIdFailed_class = NULL;
9824 static jmethodID LDKSendError_GetNodeIdFailed_meth = NULL;
9825 static jclass LDKSendError_BlindedPathAdvanceFailed_class = NULL;
9826 static jmethodID LDKSendError_BlindedPathAdvanceFailed_meth = NULL;
9827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSendError_init (JNIEnv *env, jclass clz) {
9828         LDKSendError_Secp256k1_class =
9829                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$Secp256k1"));
9830         CHECK(LDKSendError_Secp256k1_class != NULL);
9831         LDKSendError_Secp256k1_meth = (*env)->GetMethodID(env, LDKSendError_Secp256k1_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
9832         CHECK(LDKSendError_Secp256k1_meth != NULL);
9833         LDKSendError_TooBigPacket_class =
9834                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooBigPacket"));
9835         CHECK(LDKSendError_TooBigPacket_class != NULL);
9836         LDKSendError_TooBigPacket_meth = (*env)->GetMethodID(env, LDKSendError_TooBigPacket_class, "<init>", "()V");
9837         CHECK(LDKSendError_TooBigPacket_meth != NULL);
9838         LDKSendError_TooFewBlindedHops_class =
9839                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooFewBlindedHops"));
9840         CHECK(LDKSendError_TooFewBlindedHops_class != NULL);
9841         LDKSendError_TooFewBlindedHops_meth = (*env)->GetMethodID(env, LDKSendError_TooFewBlindedHops_class, "<init>", "()V");
9842         CHECK(LDKSendError_TooFewBlindedHops_meth != NULL);
9843         LDKSendError_InvalidFirstHop_class =
9844                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$InvalidFirstHop"));
9845         CHECK(LDKSendError_InvalidFirstHop_class != NULL);
9846         LDKSendError_InvalidFirstHop_meth = (*env)->GetMethodID(env, LDKSendError_InvalidFirstHop_class, "<init>", "()V");
9847         CHECK(LDKSendError_InvalidFirstHop_meth != NULL);
9848         LDKSendError_InvalidMessage_class =
9849                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$InvalidMessage"));
9850         CHECK(LDKSendError_InvalidMessage_class != NULL);
9851         LDKSendError_InvalidMessage_meth = (*env)->GetMethodID(env, LDKSendError_InvalidMessage_class, "<init>", "()V");
9852         CHECK(LDKSendError_InvalidMessage_meth != NULL);
9853         LDKSendError_BufferFull_class =
9854                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$BufferFull"));
9855         CHECK(LDKSendError_BufferFull_class != NULL);
9856         LDKSendError_BufferFull_meth = (*env)->GetMethodID(env, LDKSendError_BufferFull_class, "<init>", "()V");
9857         CHECK(LDKSendError_BufferFull_meth != NULL);
9858         LDKSendError_GetNodeIdFailed_class =
9859                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$GetNodeIdFailed"));
9860         CHECK(LDKSendError_GetNodeIdFailed_class != NULL);
9861         LDKSendError_GetNodeIdFailed_meth = (*env)->GetMethodID(env, LDKSendError_GetNodeIdFailed_class, "<init>", "()V");
9862         CHECK(LDKSendError_GetNodeIdFailed_meth != NULL);
9863         LDKSendError_BlindedPathAdvanceFailed_class =
9864                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$BlindedPathAdvanceFailed"));
9865         CHECK(LDKSendError_BlindedPathAdvanceFailed_class != NULL);
9866         LDKSendError_BlindedPathAdvanceFailed_meth = (*env)->GetMethodID(env, LDKSendError_BlindedPathAdvanceFailed_class, "<init>", "()V");
9867         CHECK(LDKSendError_BlindedPathAdvanceFailed_meth != NULL);
9868 }
9869 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSendError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9870         LDKSendError *obj = (LDKSendError*)untag_ptr(ptr);
9871         switch(obj->tag) {
9872                 case LDKSendError_Secp256k1: {
9873                         jclass secp256k1_conv = LDKSecp256k1Error_to_java(env, obj->secp256k1);
9874                         return (*env)->NewObject(env, LDKSendError_Secp256k1_class, LDKSendError_Secp256k1_meth, secp256k1_conv);
9875                 }
9876                 case LDKSendError_TooBigPacket: {
9877                         return (*env)->NewObject(env, LDKSendError_TooBigPacket_class, LDKSendError_TooBigPacket_meth);
9878                 }
9879                 case LDKSendError_TooFewBlindedHops: {
9880                         return (*env)->NewObject(env, LDKSendError_TooFewBlindedHops_class, LDKSendError_TooFewBlindedHops_meth);
9881                 }
9882                 case LDKSendError_InvalidFirstHop: {
9883                         return (*env)->NewObject(env, LDKSendError_InvalidFirstHop_class, LDKSendError_InvalidFirstHop_meth);
9884                 }
9885                 case LDKSendError_InvalidMessage: {
9886                         return (*env)->NewObject(env, LDKSendError_InvalidMessage_class, LDKSendError_InvalidMessage_meth);
9887                 }
9888                 case LDKSendError_BufferFull: {
9889                         return (*env)->NewObject(env, LDKSendError_BufferFull_class, LDKSendError_BufferFull_meth);
9890                 }
9891                 case LDKSendError_GetNodeIdFailed: {
9892                         return (*env)->NewObject(env, LDKSendError_GetNodeIdFailed_class, LDKSendError_GetNodeIdFailed_meth);
9893                 }
9894                 case LDKSendError_BlindedPathAdvanceFailed: {
9895                         return (*env)->NewObject(env, LDKSendError_BlindedPathAdvanceFailed_class, LDKSendError_BlindedPathAdvanceFailed_meth);
9896                 }
9897                 default: abort();
9898         }
9899 }
9900 static inline void CResult_NoneSendErrorZ_get_ok(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
9901 CHECK(owner->result_ok);
9902         return *owner->contents.result;
9903 }
9904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9905         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
9906         CResult_NoneSendErrorZ_get_ok(owner_conv);
9907 }
9908
9909 static inline struct LDKSendError CResult_NoneSendErrorZ_get_err(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
9910 CHECK(!owner->result_ok);
9911         return SendError_clone(&*owner->contents.err);
9912 }
9913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9914         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
9915         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
9916         *ret_copy = CResult_NoneSendErrorZ_get_err(owner_conv);
9917         int64_t ret_ref = tag_ptr(ret_copy, true);
9918         return ret_ref;
9919 }
9920
9921 static jclass LDKParseError_Bech32Error_class = NULL;
9922 static jmethodID LDKParseError_Bech32Error_meth = NULL;
9923 static jclass LDKParseError_ParseAmountError_class = NULL;
9924 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
9925 static jclass LDKParseError_MalformedSignature_class = NULL;
9926 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
9927 static jclass LDKParseError_BadPrefix_class = NULL;
9928 static jmethodID LDKParseError_BadPrefix_meth = NULL;
9929 static jclass LDKParseError_UnknownCurrency_class = NULL;
9930 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
9931 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
9932 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
9933 static jclass LDKParseError_MalformedHRP_class = NULL;
9934 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
9935 static jclass LDKParseError_TooShortDataPart_class = NULL;
9936 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
9937 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
9938 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
9939 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
9940 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
9941 static jclass LDKParseError_PaddingError_class = NULL;
9942 static jmethodID LDKParseError_PaddingError_meth = NULL;
9943 static jclass LDKParseError_IntegerOverflowError_class = NULL;
9944 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
9945 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
9946 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
9947 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
9948 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
9949 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
9950 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
9951 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
9952 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
9953 static jclass LDKParseError_InvalidSliceLength_class = NULL;
9954 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
9955 static jclass LDKParseError_Skip_class = NULL;
9956 static jmethodID LDKParseError_Skip_meth = NULL;
9957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
9958         LDKParseError_Bech32Error_class =
9959                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
9960         CHECK(LDKParseError_Bech32Error_class != NULL);
9961         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
9962         CHECK(LDKParseError_Bech32Error_meth != NULL);
9963         LDKParseError_ParseAmountError_class =
9964                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
9965         CHECK(LDKParseError_ParseAmountError_class != NULL);
9966         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
9967         CHECK(LDKParseError_ParseAmountError_meth != NULL);
9968         LDKParseError_MalformedSignature_class =
9969                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
9970         CHECK(LDKParseError_MalformedSignature_class != NULL);
9971         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
9972         CHECK(LDKParseError_MalformedSignature_meth != NULL);
9973         LDKParseError_BadPrefix_class =
9974                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
9975         CHECK(LDKParseError_BadPrefix_class != NULL);
9976         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
9977         CHECK(LDKParseError_BadPrefix_meth != NULL);
9978         LDKParseError_UnknownCurrency_class =
9979                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
9980         CHECK(LDKParseError_UnknownCurrency_class != NULL);
9981         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
9982         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
9983         LDKParseError_UnknownSiPrefix_class =
9984                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
9985         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
9986         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
9987         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
9988         LDKParseError_MalformedHRP_class =
9989                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
9990         CHECK(LDKParseError_MalformedHRP_class != NULL);
9991         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
9992         CHECK(LDKParseError_MalformedHRP_meth != NULL);
9993         LDKParseError_TooShortDataPart_class =
9994                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
9995         CHECK(LDKParseError_TooShortDataPart_class != NULL);
9996         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
9997         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
9998         LDKParseError_UnexpectedEndOfTaggedFields_class =
9999                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
10000         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
10001         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
10002         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
10003         LDKParseError_DescriptionDecodeError_class =
10004                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
10005         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
10006         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
10007         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
10008         LDKParseError_PaddingError_class =
10009                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
10010         CHECK(LDKParseError_PaddingError_class != NULL);
10011         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
10012         CHECK(LDKParseError_PaddingError_meth != NULL);
10013         LDKParseError_IntegerOverflowError_class =
10014                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
10015         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
10016         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
10017         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
10018         LDKParseError_InvalidSegWitProgramLength_class =
10019                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
10020         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
10021         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
10022         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
10023         LDKParseError_InvalidPubKeyHashLength_class =
10024                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
10025         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
10026         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
10027         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
10028         LDKParseError_InvalidScriptHashLength_class =
10029                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
10030         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
10031         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
10032         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
10033         LDKParseError_InvalidRecoveryId_class =
10034                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
10035         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
10036         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
10037         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
10038         LDKParseError_InvalidSliceLength_class =
10039                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
10040         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
10041         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
10042         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
10043         LDKParseError_Skip_class =
10044                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
10045         CHECK(LDKParseError_Skip_class != NULL);
10046         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
10047         CHECK(LDKParseError_Skip_meth != NULL);
10048 }
10049 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10050         LDKParseError *obj = (LDKParseError*)untag_ptr(ptr);
10051         switch(obj->tag) {
10052                 case LDKParseError_Bech32Error: {
10053                         int64_t bech32_error_ref = tag_ptr(&obj->bech32_error, false);
10054                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
10055                 }
10056                 case LDKParseError_ParseAmountError: {
10057                         /*obj->parse_amount_error*/
10058                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
10059                 }
10060                 case LDKParseError_MalformedSignature: {
10061                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
10062                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
10063                 }
10064                 case LDKParseError_BadPrefix: {
10065                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
10066                 }
10067                 case LDKParseError_UnknownCurrency: {
10068                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
10069                 }
10070                 case LDKParseError_UnknownSiPrefix: {
10071                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
10072                 }
10073                 case LDKParseError_MalformedHRP: {
10074                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
10075                 }
10076                 case LDKParseError_TooShortDataPart: {
10077                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
10078                 }
10079                 case LDKParseError_UnexpectedEndOfTaggedFields: {
10080                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
10081                 }
10082                 case LDKParseError_DescriptionDecodeError: {
10083                         /*obj->description_decode_error*/
10084                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
10085                 }
10086                 case LDKParseError_PaddingError: {
10087                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
10088                 }
10089                 case LDKParseError_IntegerOverflowError: {
10090                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
10091                 }
10092                 case LDKParseError_InvalidSegWitProgramLength: {
10093                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
10094                 }
10095                 case LDKParseError_InvalidPubKeyHashLength: {
10096                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
10097                 }
10098                 case LDKParseError_InvalidScriptHashLength: {
10099                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
10100                 }
10101                 case LDKParseError_InvalidRecoveryId: {
10102                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
10103                 }
10104                 case LDKParseError_InvalidSliceLength: {
10105                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
10106                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
10107                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
10108                 }
10109                 case LDKParseError_Skip: {
10110                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
10111                 }
10112                 default: abort();
10113         }
10114 }
10115 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
10116 CHECK(owner->result_ok);
10117         return SiPrefix_clone(&*owner->contents.result);
10118 }
10119 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10120         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
10121         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
10122         return ret_conv;
10123 }
10124
10125 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
10126 CHECK(!owner->result_ok);
10127         return ParseError_clone(&*owner->contents.err);
10128 }
10129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10130         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
10131         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
10132         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
10133         int64_t ret_ref = tag_ptr(ret_copy, true);
10134         return ret_ref;
10135 }
10136
10137 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
10138 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
10139 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
10140 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
10141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
10142         LDKParseOrSemanticError_ParseError_class =
10143                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
10144         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
10145         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
10146         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
10147         LDKParseOrSemanticError_SemanticError_class =
10148                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
10149         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
10150         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
10151         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
10152 }
10153 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10154         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
10155         switch(obj->tag) {
10156                 case LDKParseOrSemanticError_ParseError: {
10157                         int64_t parse_error_ref = tag_ptr(&obj->parse_error, false);
10158                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
10159                 }
10160                 case LDKParseOrSemanticError_SemanticError: {
10161                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
10162                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
10163                 }
10164                 default: abort();
10165         }
10166 }
10167 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
10168         LDKInvoice ret = *owner->contents.result;
10169         ret.is_owned = false;
10170         return ret;
10171 }
10172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10173         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
10174         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
10175         int64_t ret_ref = 0;
10176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10177         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10178         return ret_ref;
10179 }
10180
10181 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
10182 CHECK(!owner->result_ok);
10183         return ParseOrSemanticError_clone(&*owner->contents.err);
10184 }
10185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10186         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
10187         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
10188         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
10189         int64_t ret_ref = tag_ptr(ret_copy, true);
10190         return ret_ref;
10191 }
10192
10193 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
10194         LDKSignedRawInvoice ret = *owner->contents.result;
10195         ret.is_owned = false;
10196         return ret;
10197 }
10198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10199         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
10200         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
10201         int64_t ret_ref = 0;
10202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10203         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10204         return ret_ref;
10205 }
10206
10207 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
10208 CHECK(!owner->result_ok);
10209         return ParseError_clone(&*owner->contents.err);
10210 }
10211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10212         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
10213         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
10214         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
10215         int64_t ret_ref = tag_ptr(ret_copy, true);
10216         return ret_ref;
10217 }
10218
10219 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
10220         LDKRawInvoice ret = owner->a;
10221         ret.is_owned = false;
10222         return ret;
10223 }
10224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
10225         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
10226         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
10227         int64_t ret_ref = 0;
10228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10229         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10230         return ret_ref;
10231 }
10232
10233 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
10234         return ThirtyTwoBytes_clone(&owner->b);
10235 }
10236 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
10237         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
10238         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10239         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
10240         return ret_arr;
10241 }
10242
10243 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
10244         LDKInvoiceSignature ret = owner->c;
10245         ret.is_owned = false;
10246         return ret;
10247 }
10248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
10249         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
10250         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
10251         int64_t ret_ref = 0;
10252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10253         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10254         return ret_ref;
10255 }
10256
10257 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
10258         LDKPayeePubKey ret = *owner->contents.result;
10259         ret.is_owned = false;
10260         return ret;
10261 }
10262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10263         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
10264         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
10265         int64_t ret_ref = 0;
10266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10267         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10268         return ret_ref;
10269 }
10270
10271 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
10272 CHECK(!owner->result_ok);
10273         return *owner->contents.err;
10274 }
10275 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10276         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
10277         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
10278         return ret_conv;
10279 }
10280
10281 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
10282         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
10283         for (size_t i = 0; i < ret.datalen; i++) {
10284                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
10285         }
10286         return ret;
10287 }
10288 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
10289         LDKPositiveTimestamp ret = *owner->contents.result;
10290         ret.is_owned = false;
10291         return ret;
10292 }
10293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10294         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
10295         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
10296         int64_t ret_ref = 0;
10297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10298         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10299         return ret_ref;
10300 }
10301
10302 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
10303 CHECK(!owner->result_ok);
10304         return CreationError_clone(&*owner->contents.err);
10305 }
10306 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10307         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
10308         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
10309         return ret_conv;
10310 }
10311
10312 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
10313 CHECK(owner->result_ok);
10314         return *owner->contents.result;
10315 }
10316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10317         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
10318         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
10319 }
10320
10321 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
10322 CHECK(!owner->result_ok);
10323         return SemanticError_clone(&*owner->contents.err);
10324 }
10325 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10326         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
10327         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
10328         return ret_conv;
10329 }
10330
10331 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
10332         LDKInvoice ret = *owner->contents.result;
10333         ret.is_owned = false;
10334         return ret;
10335 }
10336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10337         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
10338         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
10339         int64_t ret_ref = 0;
10340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10341         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10342         return ret_ref;
10343 }
10344
10345 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
10346 CHECK(!owner->result_ok);
10347         return SemanticError_clone(&*owner->contents.err);
10348 }
10349 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10350         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
10351         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
10352         return ret_conv;
10353 }
10354
10355 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
10356         LDKDescription ret = *owner->contents.result;
10357         ret.is_owned = false;
10358         return ret;
10359 }
10360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10361         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
10362         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
10363         int64_t ret_ref = 0;
10364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10366         return ret_ref;
10367 }
10368
10369 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
10370 CHECK(!owner->result_ok);
10371         return CreationError_clone(&*owner->contents.err);
10372 }
10373 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10374         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
10375         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
10376         return ret_conv;
10377 }
10378
10379 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
10380         LDKPrivateRoute ret = *owner->contents.result;
10381         ret.is_owned = false;
10382         return ret;
10383 }
10384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10385         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
10386         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
10387         int64_t ret_ref = 0;
10388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10389         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10390         return ret_ref;
10391 }
10392
10393 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
10394 CHECK(!owner->result_ok);
10395         return CreationError_clone(&*owner->contents.err);
10396 }
10397 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10398         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
10399         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
10400         return ret_conv;
10401 }
10402
10403 static jclass LDKGraphSyncError_DecodeError_class = NULL;
10404 static jmethodID LDKGraphSyncError_DecodeError_meth = NULL;
10405 static jclass LDKGraphSyncError_LightningError_class = NULL;
10406 static jmethodID LDKGraphSyncError_LightningError_meth = NULL;
10407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGraphSyncError_init (JNIEnv *env, jclass clz) {
10408         LDKGraphSyncError_DecodeError_class =
10409                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$DecodeError"));
10410         CHECK(LDKGraphSyncError_DecodeError_class != NULL);
10411         LDKGraphSyncError_DecodeError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_DecodeError_class, "<init>", "(J)V");
10412         CHECK(LDKGraphSyncError_DecodeError_meth != NULL);
10413         LDKGraphSyncError_LightningError_class =
10414                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$LightningError"));
10415         CHECK(LDKGraphSyncError_LightningError_class != NULL);
10416         LDKGraphSyncError_LightningError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_LightningError_class, "<init>", "(J)V");
10417         CHECK(LDKGraphSyncError_LightningError_meth != NULL);
10418 }
10419 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGraphSyncError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10420         LDKGraphSyncError *obj = (LDKGraphSyncError*)untag_ptr(ptr);
10421         switch(obj->tag) {
10422                 case LDKGraphSyncError_DecodeError: {
10423                         int64_t decode_error_ref = tag_ptr(&obj->decode_error, false);
10424                         return (*env)->NewObject(env, LDKGraphSyncError_DecodeError_class, LDKGraphSyncError_DecodeError_meth, decode_error_ref);
10425                 }
10426                 case LDKGraphSyncError_LightningError: {
10427                         LDKLightningError lightning_error_var = obj->lightning_error;
10428                         int64_t lightning_error_ref = 0;
10429                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
10430                         lightning_error_ref = tag_ptr(lightning_error_var.inner, false);
10431                         return (*env)->NewObject(env, LDKGraphSyncError_LightningError_class, LDKGraphSyncError_LightningError_meth, lightning_error_ref);
10432                 }
10433                 default: abort();
10434         }
10435 }
10436 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
10437 CHECK(owner->result_ok);
10438         return *owner->contents.result;
10439 }
10440 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10441         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
10442         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
10443         return ret_conv;
10444 }
10445
10446 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
10447 CHECK(!owner->result_ok);
10448         return GraphSyncError_clone(&*owner->contents.err);
10449 }
10450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10451         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
10452         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
10453         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
10454         int64_t ret_ref = tag_ptr(ret_copy, true);
10455         return ret_ref;
10456 }
10457
10458 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
10459 CHECK(owner->result_ok);
10460         return NetAddress_clone(&*owner->contents.result);
10461 }
10462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10463         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
10464         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
10465         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
10466         int64_t ret_ref = tag_ptr(ret_copy, true);
10467         return ret_ref;
10468 }
10469
10470 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
10471 CHECK(!owner->result_ok);
10472         return DecodeError_clone(&*owner->contents.err);
10473 }
10474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10475         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
10476         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10477         *ret_copy = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
10478         int64_t ret_ref = tag_ptr(ret_copy, true);
10479         return ret_ref;
10480 }
10481
10482 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
10483         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
10484         for (size_t i = 0; i < ret.datalen; i++) {
10485                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
10486         }
10487         return ret;
10488 }
10489 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
10490         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
10491         for (size_t i = 0; i < ret.datalen; i++) {
10492                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
10493         }
10494         return ret;
10495 }
10496 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
10497         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
10498         for (size_t i = 0; i < ret.datalen; i++) {
10499                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
10500         }
10501         return ret;
10502 }
10503 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
10504         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
10505         for (size_t i = 0; i < ret.datalen; i++) {
10506                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
10507         }
10508         return ret;
10509 }
10510 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
10511         LDKAcceptChannel ret = *owner->contents.result;
10512         ret.is_owned = false;
10513         return ret;
10514 }
10515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10516         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
10517         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
10518         int64_t ret_ref = 0;
10519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10520         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10521         return ret_ref;
10522 }
10523
10524 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
10525 CHECK(!owner->result_ok);
10526         return DecodeError_clone(&*owner->contents.err);
10527 }
10528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10529         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
10530         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10531         *ret_copy = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
10532         int64_t ret_ref = tag_ptr(ret_copy, true);
10533         return ret_ref;
10534 }
10535
10536 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
10537         LDKAnnouncementSignatures ret = *owner->contents.result;
10538         ret.is_owned = false;
10539         return ret;
10540 }
10541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10542         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
10543         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
10544         int64_t ret_ref = 0;
10545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10546         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10547         return ret_ref;
10548 }
10549
10550 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
10551 CHECK(!owner->result_ok);
10552         return DecodeError_clone(&*owner->contents.err);
10553 }
10554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10555         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
10556         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10557         *ret_copy = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
10558         int64_t ret_ref = tag_ptr(ret_copy, true);
10559         return ret_ref;
10560 }
10561
10562 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
10563         LDKChannelReestablish ret = *owner->contents.result;
10564         ret.is_owned = false;
10565         return ret;
10566 }
10567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10568         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
10569         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
10570         int64_t ret_ref = 0;
10571         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10572         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10573         return ret_ref;
10574 }
10575
10576 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
10577 CHECK(!owner->result_ok);
10578         return DecodeError_clone(&*owner->contents.err);
10579 }
10580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10581         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
10582         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10583         *ret_copy = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
10584         int64_t ret_ref = tag_ptr(ret_copy, true);
10585         return ret_ref;
10586 }
10587
10588 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
10589         LDKClosingSigned ret = *owner->contents.result;
10590         ret.is_owned = false;
10591         return ret;
10592 }
10593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10594         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
10595         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
10596         int64_t ret_ref = 0;
10597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10598         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10599         return ret_ref;
10600 }
10601
10602 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
10603 CHECK(!owner->result_ok);
10604         return DecodeError_clone(&*owner->contents.err);
10605 }
10606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10607         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
10608         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10609         *ret_copy = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
10610         int64_t ret_ref = tag_ptr(ret_copy, true);
10611         return ret_ref;
10612 }
10613
10614 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
10615         LDKClosingSignedFeeRange ret = *owner->contents.result;
10616         ret.is_owned = false;
10617         return ret;
10618 }
10619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10620         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
10621         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
10622         int64_t ret_ref = 0;
10623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10624         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10625         return ret_ref;
10626 }
10627
10628 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
10629 CHECK(!owner->result_ok);
10630         return DecodeError_clone(&*owner->contents.err);
10631 }
10632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10633         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
10634         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10635         *ret_copy = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
10636         int64_t ret_ref = tag_ptr(ret_copy, true);
10637         return ret_ref;
10638 }
10639
10640 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
10641         LDKCommitmentSigned ret = *owner->contents.result;
10642         ret.is_owned = false;
10643         return ret;
10644 }
10645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10646         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
10647         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
10648         int64_t ret_ref = 0;
10649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10650         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10651         return ret_ref;
10652 }
10653
10654 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
10655 CHECK(!owner->result_ok);
10656         return DecodeError_clone(&*owner->contents.err);
10657 }
10658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10659         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
10660         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10661         *ret_copy = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
10662         int64_t ret_ref = tag_ptr(ret_copy, true);
10663         return ret_ref;
10664 }
10665
10666 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
10667         LDKFundingCreated ret = *owner->contents.result;
10668         ret.is_owned = false;
10669         return ret;
10670 }
10671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10672         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
10673         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
10674         int64_t ret_ref = 0;
10675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10676         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10677         return ret_ref;
10678 }
10679
10680 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
10681 CHECK(!owner->result_ok);
10682         return DecodeError_clone(&*owner->contents.err);
10683 }
10684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10685         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
10686         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10687         *ret_copy = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
10688         int64_t ret_ref = tag_ptr(ret_copy, true);
10689         return ret_ref;
10690 }
10691
10692 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
10693         LDKFundingSigned ret = *owner->contents.result;
10694         ret.is_owned = false;
10695         return ret;
10696 }
10697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10698         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
10699         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
10700         int64_t ret_ref = 0;
10701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10702         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10703         return ret_ref;
10704 }
10705
10706 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
10707 CHECK(!owner->result_ok);
10708         return DecodeError_clone(&*owner->contents.err);
10709 }
10710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10711         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
10712         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10713         *ret_copy = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
10714         int64_t ret_ref = tag_ptr(ret_copy, true);
10715         return ret_ref;
10716 }
10717
10718 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
10719         LDKChannelReady ret = *owner->contents.result;
10720         ret.is_owned = false;
10721         return ret;
10722 }
10723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10724         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
10725         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
10726         int64_t ret_ref = 0;
10727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10728         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10729         return ret_ref;
10730 }
10731
10732 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
10733 CHECK(!owner->result_ok);
10734         return DecodeError_clone(&*owner->contents.err);
10735 }
10736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10737         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
10738         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10739         *ret_copy = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
10740         int64_t ret_ref = tag_ptr(ret_copy, true);
10741         return ret_ref;
10742 }
10743
10744 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
10745         LDKInit ret = *owner->contents.result;
10746         ret.is_owned = false;
10747         return ret;
10748 }
10749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10750         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
10751         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
10752         int64_t ret_ref = 0;
10753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10754         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10755         return ret_ref;
10756 }
10757
10758 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
10759 CHECK(!owner->result_ok);
10760         return DecodeError_clone(&*owner->contents.err);
10761 }
10762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10763         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
10764         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10765         *ret_copy = CResult_InitDecodeErrorZ_get_err(owner_conv);
10766         int64_t ret_ref = tag_ptr(ret_copy, true);
10767         return ret_ref;
10768 }
10769
10770 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
10771         LDKOpenChannel ret = *owner->contents.result;
10772         ret.is_owned = false;
10773         return ret;
10774 }
10775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10776         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
10777         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
10778         int64_t ret_ref = 0;
10779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10780         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10781         return ret_ref;
10782 }
10783
10784 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
10785 CHECK(!owner->result_ok);
10786         return DecodeError_clone(&*owner->contents.err);
10787 }
10788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10789         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
10790         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10791         *ret_copy = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
10792         int64_t ret_ref = tag_ptr(ret_copy, true);
10793         return ret_ref;
10794 }
10795
10796 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
10797         LDKRevokeAndACK ret = *owner->contents.result;
10798         ret.is_owned = false;
10799         return ret;
10800 }
10801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10802         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
10803         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
10804         int64_t ret_ref = 0;
10805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10806         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10807         return ret_ref;
10808 }
10809
10810 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
10811 CHECK(!owner->result_ok);
10812         return DecodeError_clone(&*owner->contents.err);
10813 }
10814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10815         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
10816         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10817         *ret_copy = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
10818         int64_t ret_ref = tag_ptr(ret_copy, true);
10819         return ret_ref;
10820 }
10821
10822 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
10823         LDKShutdown ret = *owner->contents.result;
10824         ret.is_owned = false;
10825         return ret;
10826 }
10827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10828         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
10829         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
10830         int64_t ret_ref = 0;
10831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10832         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10833         return ret_ref;
10834 }
10835
10836 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
10837 CHECK(!owner->result_ok);
10838         return DecodeError_clone(&*owner->contents.err);
10839 }
10840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10841         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
10842         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10843         *ret_copy = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
10844         int64_t ret_ref = tag_ptr(ret_copy, true);
10845         return ret_ref;
10846 }
10847
10848 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
10849         LDKUpdateFailHTLC ret = *owner->contents.result;
10850         ret.is_owned = false;
10851         return ret;
10852 }
10853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10854         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
10855         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
10856         int64_t ret_ref = 0;
10857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10858         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10859         return ret_ref;
10860 }
10861
10862 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
10863 CHECK(!owner->result_ok);
10864         return DecodeError_clone(&*owner->contents.err);
10865 }
10866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10867         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
10868         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10869         *ret_copy = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
10870         int64_t ret_ref = tag_ptr(ret_copy, true);
10871         return ret_ref;
10872 }
10873
10874 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
10875         LDKUpdateFailMalformedHTLC ret = *owner->contents.result;
10876         ret.is_owned = false;
10877         return ret;
10878 }
10879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10880         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
10881         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
10882         int64_t ret_ref = 0;
10883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10884         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10885         return ret_ref;
10886 }
10887
10888 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
10889 CHECK(!owner->result_ok);
10890         return DecodeError_clone(&*owner->contents.err);
10891 }
10892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10893         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
10894         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10895         *ret_copy = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
10896         int64_t ret_ref = tag_ptr(ret_copy, true);
10897         return ret_ref;
10898 }
10899
10900 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
10901         LDKUpdateFee ret = *owner->contents.result;
10902         ret.is_owned = false;
10903         return ret;
10904 }
10905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10906         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
10907         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
10908         int64_t ret_ref = 0;
10909         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10910         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10911         return ret_ref;
10912 }
10913
10914 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
10915 CHECK(!owner->result_ok);
10916         return DecodeError_clone(&*owner->contents.err);
10917 }
10918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10919         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
10920         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10921         *ret_copy = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
10922         int64_t ret_ref = tag_ptr(ret_copy, true);
10923         return ret_ref;
10924 }
10925
10926 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
10927         LDKUpdateFulfillHTLC ret = *owner->contents.result;
10928         ret.is_owned = false;
10929         return ret;
10930 }
10931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10932         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
10933         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
10934         int64_t ret_ref = 0;
10935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10936         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10937         return ret_ref;
10938 }
10939
10940 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
10941 CHECK(!owner->result_ok);
10942         return DecodeError_clone(&*owner->contents.err);
10943 }
10944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10945         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
10946         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10947         *ret_copy = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
10948         int64_t ret_ref = tag_ptr(ret_copy, true);
10949         return ret_ref;
10950 }
10951
10952 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
10953         LDKUpdateAddHTLC ret = *owner->contents.result;
10954         ret.is_owned = false;
10955         return ret;
10956 }
10957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10958         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
10959         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
10960         int64_t ret_ref = 0;
10961         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10962         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10963         return ret_ref;
10964 }
10965
10966 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
10967 CHECK(!owner->result_ok);
10968         return DecodeError_clone(&*owner->contents.err);
10969 }
10970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10971         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
10972         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10973         *ret_copy = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
10974         int64_t ret_ref = tag_ptr(ret_copy, true);
10975         return ret_ref;
10976 }
10977
10978 static inline struct LDKOnionMessage CResult_OnionMessageDecodeErrorZ_get_ok(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
10979         LDKOnionMessage ret = *owner->contents.result;
10980         ret.is_owned = false;
10981         return ret;
10982 }
10983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10984         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
10985         LDKOnionMessage ret_var = CResult_OnionMessageDecodeErrorZ_get_ok(owner_conv);
10986         int64_t ret_ref = 0;
10987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10989         return ret_ref;
10990 }
10991
10992 static inline struct LDKDecodeError CResult_OnionMessageDecodeErrorZ_get_err(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
10993 CHECK(!owner->result_ok);
10994         return DecodeError_clone(&*owner->contents.err);
10995 }
10996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10997         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
10998         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10999         *ret_copy = CResult_OnionMessageDecodeErrorZ_get_err(owner_conv);
11000         int64_t ret_ref = tag_ptr(ret_copy, true);
11001         return ret_ref;
11002 }
11003
11004 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
11005         LDKPing ret = *owner->contents.result;
11006         ret.is_owned = false;
11007         return ret;
11008 }
11009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11010         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
11011         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
11012         int64_t ret_ref = 0;
11013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11014         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11015         return ret_ref;
11016 }
11017
11018 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
11019 CHECK(!owner->result_ok);
11020         return DecodeError_clone(&*owner->contents.err);
11021 }
11022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11023         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
11024         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11025         *ret_copy = CResult_PingDecodeErrorZ_get_err(owner_conv);
11026         int64_t ret_ref = tag_ptr(ret_copy, true);
11027         return ret_ref;
11028 }
11029
11030 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
11031         LDKPong ret = *owner->contents.result;
11032         ret.is_owned = false;
11033         return ret;
11034 }
11035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11036         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
11037         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
11038         int64_t ret_ref = 0;
11039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11040         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11041         return ret_ref;
11042 }
11043
11044 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
11045 CHECK(!owner->result_ok);
11046         return DecodeError_clone(&*owner->contents.err);
11047 }
11048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11049         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
11050         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11051         *ret_copy = CResult_PongDecodeErrorZ_get_err(owner_conv);
11052         int64_t ret_ref = tag_ptr(ret_copy, true);
11053         return ret_ref;
11054 }
11055
11056 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11057         LDKUnsignedChannelAnnouncement ret = *owner->contents.result;
11058         ret.is_owned = false;
11059         return ret;
11060 }
11061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11062         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
11063         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
11064         int64_t ret_ref = 0;
11065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11066         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11067         return ret_ref;
11068 }
11069
11070 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11071 CHECK(!owner->result_ok);
11072         return DecodeError_clone(&*owner->contents.err);
11073 }
11074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11075         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
11076         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11077         *ret_copy = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
11078         int64_t ret_ref = tag_ptr(ret_copy, true);
11079         return ret_ref;
11080 }
11081
11082 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11083         LDKChannelAnnouncement ret = *owner->contents.result;
11084         ret.is_owned = false;
11085         return ret;
11086 }
11087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11088         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
11089         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
11090         int64_t ret_ref = 0;
11091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11092         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11093         return ret_ref;
11094 }
11095
11096 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11097 CHECK(!owner->result_ok);
11098         return DecodeError_clone(&*owner->contents.err);
11099 }
11100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11101         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
11102         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11103         *ret_copy = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
11104         int64_t ret_ref = tag_ptr(ret_copy, true);
11105         return ret_ref;
11106 }
11107
11108 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
11109         LDKUnsignedChannelUpdate ret = *owner->contents.result;
11110         ret.is_owned = false;
11111         return ret;
11112 }
11113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11114         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
11115         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
11116         int64_t ret_ref = 0;
11117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11118         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11119         return ret_ref;
11120 }
11121
11122 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
11123 CHECK(!owner->result_ok);
11124         return DecodeError_clone(&*owner->contents.err);
11125 }
11126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11127         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
11128         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11129         *ret_copy = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
11130         int64_t ret_ref = tag_ptr(ret_copy, true);
11131         return ret_ref;
11132 }
11133
11134 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
11135         LDKChannelUpdate ret = *owner->contents.result;
11136         ret.is_owned = false;
11137         return ret;
11138 }
11139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11140         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
11141         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
11142         int64_t ret_ref = 0;
11143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11144         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11145         return ret_ref;
11146 }
11147
11148 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
11149 CHECK(!owner->result_ok);
11150         return DecodeError_clone(&*owner->contents.err);
11151 }
11152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11153         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
11154         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11155         *ret_copy = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
11156         int64_t ret_ref = tag_ptr(ret_copy, true);
11157         return ret_ref;
11158 }
11159
11160 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
11161         LDKErrorMessage ret = *owner->contents.result;
11162         ret.is_owned = false;
11163         return ret;
11164 }
11165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11166         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
11167         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
11168         int64_t ret_ref = 0;
11169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11170         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11171         return ret_ref;
11172 }
11173
11174 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
11175 CHECK(!owner->result_ok);
11176         return DecodeError_clone(&*owner->contents.err);
11177 }
11178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11179         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
11180         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11181         *ret_copy = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
11182         int64_t ret_ref = tag_ptr(ret_copy, true);
11183         return ret_ref;
11184 }
11185
11186 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
11187         LDKWarningMessage ret = *owner->contents.result;
11188         ret.is_owned = false;
11189         return ret;
11190 }
11191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11192         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
11193         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
11194         int64_t ret_ref = 0;
11195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11196         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11197         return ret_ref;
11198 }
11199
11200 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
11201 CHECK(!owner->result_ok);
11202         return DecodeError_clone(&*owner->contents.err);
11203 }
11204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11205         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
11206         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11207         *ret_copy = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
11208         int64_t ret_ref = tag_ptr(ret_copy, true);
11209         return ret_ref;
11210 }
11211
11212 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11213         LDKUnsignedNodeAnnouncement ret = *owner->contents.result;
11214         ret.is_owned = false;
11215         return ret;
11216 }
11217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11218         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
11219         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
11220         int64_t ret_ref = 0;
11221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11222         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11223         return ret_ref;
11224 }
11225
11226 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11227 CHECK(!owner->result_ok);
11228         return DecodeError_clone(&*owner->contents.err);
11229 }
11230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11231         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
11232         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11233         *ret_copy = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
11234         int64_t ret_ref = tag_ptr(ret_copy, true);
11235         return ret_ref;
11236 }
11237
11238 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11239         LDKNodeAnnouncement ret = *owner->contents.result;
11240         ret.is_owned = false;
11241         return ret;
11242 }
11243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11244         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
11245         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
11246         int64_t ret_ref = 0;
11247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11248         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11249         return ret_ref;
11250 }
11251
11252 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11253 CHECK(!owner->result_ok);
11254         return DecodeError_clone(&*owner->contents.err);
11255 }
11256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11257         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
11258         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11259         *ret_copy = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
11260         int64_t ret_ref = tag_ptr(ret_copy, true);
11261         return ret_ref;
11262 }
11263
11264 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
11265         LDKQueryShortChannelIds ret = *owner->contents.result;
11266         ret.is_owned = false;
11267         return ret;
11268 }
11269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11270         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
11271         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
11272         int64_t ret_ref = 0;
11273         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11274         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11275         return ret_ref;
11276 }
11277
11278 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
11279 CHECK(!owner->result_ok);
11280         return DecodeError_clone(&*owner->contents.err);
11281 }
11282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11283         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
11284         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11285         *ret_copy = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
11286         int64_t ret_ref = tag_ptr(ret_copy, true);
11287         return ret_ref;
11288 }
11289
11290 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
11291         LDKReplyShortChannelIdsEnd ret = *owner->contents.result;
11292         ret.is_owned = false;
11293         return ret;
11294 }
11295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11296         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
11297         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
11298         int64_t ret_ref = 0;
11299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11300         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11301         return ret_ref;
11302 }
11303
11304 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
11305 CHECK(!owner->result_ok);
11306         return DecodeError_clone(&*owner->contents.err);
11307 }
11308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11309         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
11310         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11311         *ret_copy = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
11312         int64_t ret_ref = tag_ptr(ret_copy, true);
11313         return ret_ref;
11314 }
11315
11316 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
11317         LDKQueryChannelRange ret = *owner->contents.result;
11318         ret.is_owned = false;
11319         return ret;
11320 }
11321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11322         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
11323         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
11324         int64_t ret_ref = 0;
11325         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11326         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11327         return ret_ref;
11328 }
11329
11330 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
11331 CHECK(!owner->result_ok);
11332         return DecodeError_clone(&*owner->contents.err);
11333 }
11334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11335         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
11336         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11337         *ret_copy = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
11338         int64_t ret_ref = tag_ptr(ret_copy, true);
11339         return ret_ref;
11340 }
11341
11342 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
11343         LDKReplyChannelRange ret = *owner->contents.result;
11344         ret.is_owned = false;
11345         return ret;
11346 }
11347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11348         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
11349         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
11350         int64_t ret_ref = 0;
11351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11352         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11353         return ret_ref;
11354 }
11355
11356 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
11357 CHECK(!owner->result_ok);
11358         return DecodeError_clone(&*owner->contents.err);
11359 }
11360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11361         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
11362         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11363         *ret_copy = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
11364         int64_t ret_ref = tag_ptr(ret_copy, true);
11365         return ret_ref;
11366 }
11367
11368 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
11369         LDKGossipTimestampFilter ret = *owner->contents.result;
11370         ret.is_owned = false;
11371         return ret;
11372 }
11373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11374         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
11375         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
11376         int64_t ret_ref = 0;
11377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11378         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11379         return ret_ref;
11380 }
11381
11382 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
11383 CHECK(!owner->result_ok);
11384         return DecodeError_clone(&*owner->contents.err);
11385 }
11386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11387         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
11388         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11389         *ret_copy = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
11390         int64_t ret_ref = tag_ptr(ret_copy, true);
11391         return ret_ref;
11392 }
11393
11394 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
11395         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
11396         for (size_t i = 0; i < ret.datalen; i++) {
11397                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
11398         }
11399         return ret;
11400 }
11401 static jclass LDKSignOrCreationError_SignError_class = NULL;
11402 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
11403 static jclass LDKSignOrCreationError_CreationError_class = NULL;
11404 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
11405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
11406         LDKSignOrCreationError_SignError_class =
11407                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
11408         CHECK(LDKSignOrCreationError_SignError_class != NULL);
11409         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
11410         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
11411         LDKSignOrCreationError_CreationError_class =
11412                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
11413         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
11414         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
11415         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
11416 }
11417 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
11418         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)untag_ptr(ptr);
11419         switch(obj->tag) {
11420                 case LDKSignOrCreationError_SignError: {
11421                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
11422                 }
11423                 case LDKSignOrCreationError_CreationError: {
11424                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
11425                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
11426                 }
11427                 default: abort();
11428         }
11429 }
11430 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
11431         LDKInvoice ret = *owner->contents.result;
11432         ret.is_owned = false;
11433         return ret;
11434 }
11435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11436         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
11437         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
11438         int64_t ret_ref = 0;
11439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11440         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11441         return ret_ref;
11442 }
11443
11444 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
11445 CHECK(!owner->result_ok);
11446         return SignOrCreationError_clone(&*owner->contents.err);
11447 }
11448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11449         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
11450         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
11451         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
11452         int64_t ret_ref = tag_ptr(ret_copy, true);
11453         return ret_ref;
11454 }
11455
11456 typedef struct LDKFilter_JCalls {
11457         atomic_size_t refcnt;
11458         JavaVM *vm;
11459         jweak o;
11460         jmethodID register_tx_meth;
11461         jmethodID register_output_meth;
11462 } LDKFilter_JCalls;
11463 static void LDKFilter_JCalls_free(void* this_arg) {
11464         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
11465         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11466                 JNIEnv *env;
11467                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11468                 if (get_jenv_res == JNI_EDETACHED) {
11469                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11470                 } else {
11471                         DO_ASSERT(get_jenv_res == JNI_OK);
11472                 }
11473                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11474                 if (get_jenv_res == JNI_EDETACHED) {
11475                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11476                 }
11477                 FREE(j_calls);
11478         }
11479 }
11480 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
11481         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
11482         JNIEnv *env;
11483         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11484         if (get_jenv_res == JNI_EDETACHED) {
11485                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11486         } else {
11487                 DO_ASSERT(get_jenv_res == JNI_OK);
11488         }
11489         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
11490         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
11491         LDKu8slice script_pubkey_var = script_pubkey;
11492         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
11493         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
11494         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11495         CHECK(obj != NULL);
11496         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
11497         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11498                 (*env)->ExceptionDescribe(env);
11499                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
11500         }
11501         if (get_jenv_res == JNI_EDETACHED) {
11502                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11503         }
11504 }
11505 void register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
11506         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
11507         JNIEnv *env;
11508         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11509         if (get_jenv_res == JNI_EDETACHED) {
11510                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11511         } else {
11512                 DO_ASSERT(get_jenv_res == JNI_OK);
11513         }
11514         LDKWatchedOutput output_var = output;
11515         int64_t output_ref = 0;
11516         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
11517         output_ref = tag_ptr(output_var.inner, output_var.is_owned);
11518         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11519         CHECK(obj != NULL);
11520         (*env)->CallVoidMethod(env, obj, j_calls->register_output_meth, output_ref);
11521         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11522                 (*env)->ExceptionDescribe(env);
11523                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
11524         }
11525         if (get_jenv_res == JNI_EDETACHED) {
11526                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11527         }
11528 }
11529 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
11530         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
11531         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11532 }
11533 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
11534         jclass c = (*env)->GetObjectClass(env, o);
11535         CHECK(c != NULL);
11536         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
11537         atomic_init(&calls->refcnt, 1);
11538         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11539         calls->o = (*env)->NewWeakGlobalRef(env, o);
11540         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
11541         CHECK(calls->register_tx_meth != NULL);
11542         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)V");
11543         CHECK(calls->register_output_meth != NULL);
11544
11545         LDKFilter ret = {
11546                 .this_arg = (void*) calls,
11547                 .register_tx = register_tx_LDKFilter_jcall,
11548                 .register_output = register_output_LDKFilter_jcall,
11549                 .free = LDKFilter_JCalls_free,
11550         };
11551         return ret;
11552 }
11553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
11554         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
11555         *res_ptr = LDKFilter_init(env, clz, o);
11556         return tag_ptr(res_ptr, true);
11557 }
11558 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) {
11559         void* this_arg_ptr = untag_ptr(this_arg);
11560         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11561         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
11562         uint8_t txid_arr[32];
11563         CHECK((*env)->GetArrayLength(env, txid) == 32);
11564         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11565         uint8_t (*txid_ref)[32] = &txid_arr;
11566         LDKu8slice script_pubkey_ref;
11567         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
11568         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
11569         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
11570         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
11571 }
11572
11573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
11574         void* this_arg_ptr = untag_ptr(this_arg);
11575         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11576         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
11577         LDKWatchedOutput output_conv;
11578         output_conv.inner = untag_ptr(output);
11579         output_conv.is_owned = ptr_is_owned(output);
11580         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
11581         output_conv = WatchedOutput_clone(&output_conv);
11582         (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
11583 }
11584
11585 static jclass LDKCOption_FilterZ_Some_class = NULL;
11586 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
11587 static jclass LDKCOption_FilterZ_None_class = NULL;
11588 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
11589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
11590         LDKCOption_FilterZ_Some_class =
11591                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
11592         CHECK(LDKCOption_FilterZ_Some_class != NULL);
11593         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
11594         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
11595         LDKCOption_FilterZ_None_class =
11596                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
11597         CHECK(LDKCOption_FilterZ_None_class != NULL);
11598         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
11599         CHECK(LDKCOption_FilterZ_None_meth != NULL);
11600 }
11601 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
11602         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)untag_ptr(ptr);
11603         switch(obj->tag) {
11604                 case LDKCOption_FilterZ_Some: {
11605                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
11606                         *some_ret = obj->some;
11607                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
11608                         if ((*some_ret).free == LDKFilter_JCalls_free) {
11609                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11610                                 LDKFilter_JCalls_cloned(&(*some_ret));
11611                         }
11612                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, tag_ptr(some_ret, true));
11613                 }
11614                 case LDKCOption_FilterZ_None: {
11615                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
11616                 }
11617                 default: abort();
11618         }
11619 }
11620 static inline struct LDKLockedChannelMonitor CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
11621         LDKLockedChannelMonitor ret = *owner->contents.result;
11622         ret.is_owned = false;
11623         return ret;
11624 }
11625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11626         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
11627         LDKLockedChannelMonitor ret_var = CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
11628         int64_t ret_ref = 0;
11629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11630         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11631         return ret_ref;
11632 }
11633
11634 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
11635 CHECK(!owner->result_ok);
11636         return *owner->contents.err;
11637 }
11638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11639         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
11640         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
11641 }
11642
11643 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
11644         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
11645         for (size_t i = 0; i < ret.datalen; i++) {
11646                 ret.data[i] = OutPoint_clone(&orig->data[i]);
11647         }
11648         return ret;
11649 }
11650 static inline LDKCVec_MonitorUpdateIdZ CVec_MonitorUpdateIdZ_clone(const LDKCVec_MonitorUpdateIdZ *orig) {
11651         LDKCVec_MonitorUpdateIdZ ret = { .data = MALLOC(sizeof(LDKMonitorUpdateId) * orig->datalen, "LDKCVec_MonitorUpdateIdZ clone bytes"), .datalen = orig->datalen };
11652         for (size_t i = 0; i < ret.datalen; i++) {
11653                 ret.data[i] = MonitorUpdateId_clone(&orig->data[i]);
11654         }
11655         return ret;
11656 }
11657 static inline struct LDKOutPoint C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR owner){
11658         LDKOutPoint ret = owner->a;
11659         ret.is_owned = false;
11660         return ret;
11661 }
11662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
11663         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(owner);
11664         LDKOutPoint ret_var = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(owner_conv);
11665         int64_t ret_ref = 0;
11666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11667         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11668         return ret_ref;
11669 }
11670
11671 static inline struct LDKCVec_MonitorUpdateIdZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR owner){
11672         return CVec_MonitorUpdateIdZ_clone(&owner->b);
11673 }
11674 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
11675         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(owner);
11676         LDKCVec_MonitorUpdateIdZ ret_var = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(owner_conv);
11677         int64_tArray ret_arr = NULL;
11678         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11679         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11680         for (size_t r = 0; r < ret_var.datalen; r++) {
11681                 LDKMonitorUpdateId ret_conv_17_var = ret_var.data[r];
11682                 int64_t ret_conv_17_ref = 0;
11683                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_17_var);
11684                 ret_conv_17_ref = tag_ptr(ret_conv_17_var.inner, ret_conv_17_var.is_owned);
11685                 ret_arr_ptr[r] = ret_conv_17_ref;
11686         }
11687         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11688         FREE(ret_var.data);
11689         return ret_arr;
11690 }
11691
11692 static inline LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_clone(const LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ *orig) {
11693         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ) * orig->datalen, "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ clone bytes"), .datalen = orig->datalen };
11694         for (size_t i = 0; i < ret.datalen; i++) {
11695                 ret.data[i] = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(&orig->data[i]);
11696         }
11697         return ret;
11698 }
11699 typedef struct LDKMessageSendEventsProvider_JCalls {
11700         atomic_size_t refcnt;
11701         JavaVM *vm;
11702         jweak o;
11703         jmethodID get_and_clear_pending_msg_events_meth;
11704 } LDKMessageSendEventsProvider_JCalls;
11705 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
11706         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
11707         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11708                 JNIEnv *env;
11709                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11710                 if (get_jenv_res == JNI_EDETACHED) {
11711                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11712                 } else {
11713                         DO_ASSERT(get_jenv_res == JNI_OK);
11714                 }
11715                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11716                 if (get_jenv_res == JNI_EDETACHED) {
11717                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11718                 }
11719                 FREE(j_calls);
11720         }
11721 }
11722 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
11723         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
11724         JNIEnv *env;
11725         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11726         if (get_jenv_res == JNI_EDETACHED) {
11727                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11728         } else {
11729                 DO_ASSERT(get_jenv_res == JNI_OK);
11730         }
11731         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11732         CHECK(obj != NULL);
11733         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
11734         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11735                 (*env)->ExceptionDescribe(env);
11736                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
11737         }
11738         LDKCVec_MessageSendEventZ ret_constr;
11739         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11740         if (ret_constr.datalen > 0)
11741                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
11742         else
11743                 ret_constr.data = NULL;
11744         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
11745         for (size_t s = 0; s < ret_constr.datalen; s++) {
11746                 int64_t ret_conv_18 = ret_vals[s];
11747                 void* ret_conv_18_ptr = untag_ptr(ret_conv_18);
11748                 CHECK_ACCESS(ret_conv_18_ptr);
11749                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
11750                 FREE(untag_ptr(ret_conv_18));
11751                 ret_constr.data[s] = ret_conv_18_conv;
11752         }
11753         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
11754         if (get_jenv_res == JNI_EDETACHED) {
11755                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11756         }
11757         return ret_constr;
11758 }
11759 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
11760         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
11761         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11762 }
11763 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
11764         jclass c = (*env)->GetObjectClass(env, o);
11765         CHECK(c != NULL);
11766         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
11767         atomic_init(&calls->refcnt, 1);
11768         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11769         calls->o = (*env)->NewWeakGlobalRef(env, o);
11770         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
11771         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
11772
11773         LDKMessageSendEventsProvider ret = {
11774                 .this_arg = (void*) calls,
11775                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
11776                 .free = LDKMessageSendEventsProvider_JCalls_free,
11777         };
11778         return ret;
11779 }
11780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
11781         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
11782         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
11783         return tag_ptr(res_ptr, true);
11784 }
11785 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
11786         void* this_arg_ptr = untag_ptr(this_arg);
11787         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11788         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
11789         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
11790         int64_tArray ret_arr = NULL;
11791         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11792         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11793         for (size_t s = 0; s < ret_var.datalen; s++) {
11794                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11795                 *ret_conv_18_copy = ret_var.data[s];
11796                 int64_t ret_conv_18_ref = tag_ptr(ret_conv_18_copy, true);
11797                 ret_arr_ptr[s] = ret_conv_18_ref;
11798         }
11799         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11800         FREE(ret_var.data);
11801         return ret_arr;
11802 }
11803
11804 typedef struct LDKOnionMessageProvider_JCalls {
11805         atomic_size_t refcnt;
11806         JavaVM *vm;
11807         jweak o;
11808         jmethodID next_onion_message_for_peer_meth;
11809 } LDKOnionMessageProvider_JCalls;
11810 static void LDKOnionMessageProvider_JCalls_free(void* this_arg) {
11811         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
11812         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11813                 JNIEnv *env;
11814                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11815                 if (get_jenv_res == JNI_EDETACHED) {
11816                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11817                 } else {
11818                         DO_ASSERT(get_jenv_res == JNI_OK);
11819                 }
11820                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11821                 if (get_jenv_res == JNI_EDETACHED) {
11822                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11823                 }
11824                 FREE(j_calls);
11825         }
11826 }
11827 LDKOnionMessage next_onion_message_for_peer_LDKOnionMessageProvider_jcall(const void* this_arg, LDKPublicKey peer_node_id) {
11828         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
11829         JNIEnv *env;
11830         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11831         if (get_jenv_res == JNI_EDETACHED) {
11832                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11833         } else {
11834                 DO_ASSERT(get_jenv_res == JNI_OK);
11835         }
11836         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
11837         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
11838         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11839         CHECK(obj != NULL);
11840         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->next_onion_message_for_peer_meth, peer_node_id_arr);
11841         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11842                 (*env)->ExceptionDescribe(env);
11843                 (*env)->FatalError(env, "A call to next_onion_message_for_peer in LDKOnionMessageProvider from rust threw an exception.");
11844         }
11845         LDKOnionMessage ret_conv;
11846         ret_conv.inner = untag_ptr(ret);
11847         ret_conv.is_owned = ptr_is_owned(ret);
11848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
11849         if (get_jenv_res == JNI_EDETACHED) {
11850                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11851         }
11852         return ret_conv;
11853 }
11854 static void LDKOnionMessageProvider_JCalls_cloned(LDKOnionMessageProvider* new_obj) {
11855         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) new_obj->this_arg;
11856         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11857 }
11858 static inline LDKOnionMessageProvider LDKOnionMessageProvider_init (JNIEnv *env, jclass clz, jobject o) {
11859         jclass c = (*env)->GetObjectClass(env, o);
11860         CHECK(c != NULL);
11861         LDKOnionMessageProvider_JCalls *calls = MALLOC(sizeof(LDKOnionMessageProvider_JCalls), "LDKOnionMessageProvider_JCalls");
11862         atomic_init(&calls->refcnt, 1);
11863         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11864         calls->o = (*env)->NewWeakGlobalRef(env, o);
11865         calls->next_onion_message_for_peer_meth = (*env)->GetMethodID(env, c, "next_onion_message_for_peer", "([B)J");
11866         CHECK(calls->next_onion_message_for_peer_meth != NULL);
11867
11868         LDKOnionMessageProvider ret = {
11869                 .this_arg = (void*) calls,
11870                 .next_onion_message_for_peer = next_onion_message_for_peer_LDKOnionMessageProvider_jcall,
11871                 .free = LDKOnionMessageProvider_JCalls_free,
11872         };
11873         return ret;
11874 }
11875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageProvider_1new(JNIEnv *env, jclass clz, jobject o) {
11876         LDKOnionMessageProvider *res_ptr = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
11877         *res_ptr = LDKOnionMessageProvider_init(env, clz, o);
11878         return tag_ptr(res_ptr, true);
11879 }
11880 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) {
11881         void* this_arg_ptr = untag_ptr(this_arg);
11882         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11883         LDKOnionMessageProvider* this_arg_conv = (LDKOnionMessageProvider*)this_arg_ptr;
11884         LDKPublicKey peer_node_id_ref;
11885         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
11886         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
11887         LDKOnionMessage ret_var = (this_arg_conv->next_onion_message_for_peer)(this_arg_conv->this_arg, peer_node_id_ref);
11888         int64_t ret_ref = 0;
11889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11890         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11891         return ret_ref;
11892 }
11893
11894 typedef struct LDKEventHandler_JCalls {
11895         atomic_size_t refcnt;
11896         JavaVM *vm;
11897         jweak o;
11898         jmethodID handle_event_meth;
11899 } LDKEventHandler_JCalls;
11900 static void LDKEventHandler_JCalls_free(void* this_arg) {
11901         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
11902         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11903                 JNIEnv *env;
11904                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11905                 if (get_jenv_res == JNI_EDETACHED) {
11906                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11907                 } else {
11908                         DO_ASSERT(get_jenv_res == JNI_OK);
11909                 }
11910                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11911                 if (get_jenv_res == JNI_EDETACHED) {
11912                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11913                 }
11914                 FREE(j_calls);
11915         }
11916 }
11917 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
11918         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
11919         JNIEnv *env;
11920         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11921         if (get_jenv_res == JNI_EDETACHED) {
11922                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11923         } else {
11924                 DO_ASSERT(get_jenv_res == JNI_OK);
11925         }
11926         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11927         *event_copy = event;
11928         int64_t event_ref = tag_ptr(event_copy, true);
11929         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11930         CHECK(obj != NULL);
11931         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
11932         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11933                 (*env)->ExceptionDescribe(env);
11934                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
11935         }
11936         if (get_jenv_res == JNI_EDETACHED) {
11937                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11938         }
11939 }
11940 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
11941         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
11942         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11943 }
11944 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
11945         jclass c = (*env)->GetObjectClass(env, o);
11946         CHECK(c != NULL);
11947         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
11948         atomic_init(&calls->refcnt, 1);
11949         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11950         calls->o = (*env)->NewWeakGlobalRef(env, o);
11951         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
11952         CHECK(calls->handle_event_meth != NULL);
11953
11954         LDKEventHandler ret = {
11955                 .this_arg = (void*) calls,
11956                 .handle_event = handle_event_LDKEventHandler_jcall,
11957                 .free = LDKEventHandler_JCalls_free,
11958         };
11959         return ret;
11960 }
11961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
11962         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
11963         *res_ptr = LDKEventHandler_init(env, clz, o);
11964         return tag_ptr(res_ptr, true);
11965 }
11966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
11967         void* this_arg_ptr = untag_ptr(this_arg);
11968         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11969         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
11970         void* event_ptr = untag_ptr(event);
11971         CHECK_ACCESS(event_ptr);
11972         LDKEvent event_conv = *(LDKEvent*)(event_ptr);
11973         event_conv = Event_clone((LDKEvent*)untag_ptr(event));
11974         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
11975 }
11976
11977 typedef struct LDKEventsProvider_JCalls {
11978         atomic_size_t refcnt;
11979         JavaVM *vm;
11980         jweak o;
11981         jmethodID process_pending_events_meth;
11982 } LDKEventsProvider_JCalls;
11983 static void LDKEventsProvider_JCalls_free(void* this_arg) {
11984         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
11985         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11986                 JNIEnv *env;
11987                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11988                 if (get_jenv_res == JNI_EDETACHED) {
11989                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11990                 } else {
11991                         DO_ASSERT(get_jenv_res == JNI_OK);
11992                 }
11993                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11994                 if (get_jenv_res == JNI_EDETACHED) {
11995                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11996                 }
11997                 FREE(j_calls);
11998         }
11999 }
12000 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
12001         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
12002         JNIEnv *env;
12003         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12004         if (get_jenv_res == JNI_EDETACHED) {
12005                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12006         } else {
12007                 DO_ASSERT(get_jenv_res == JNI_OK);
12008         }
12009         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
12010         *handler_ret = handler;
12011         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12012         CHECK(obj != NULL);
12013         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, tag_ptr(handler_ret, true));
12014         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12015                 (*env)->ExceptionDescribe(env);
12016                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
12017         }
12018         if (get_jenv_res == JNI_EDETACHED) {
12019                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12020         }
12021 }
12022 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
12023         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
12024         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12025 }
12026 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
12027         jclass c = (*env)->GetObjectClass(env, o);
12028         CHECK(c != NULL);
12029         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
12030         atomic_init(&calls->refcnt, 1);
12031         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12032         calls->o = (*env)->NewWeakGlobalRef(env, o);
12033         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
12034         CHECK(calls->process_pending_events_meth != NULL);
12035
12036         LDKEventsProvider ret = {
12037                 .this_arg = (void*) calls,
12038                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
12039                 .free = LDKEventsProvider_JCalls_free,
12040         };
12041         return ret;
12042 }
12043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
12044         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
12045         *res_ptr = LDKEventsProvider_init(env, clz, o);
12046         return tag_ptr(res_ptr, true);
12047 }
12048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
12049         void* this_arg_ptr = untag_ptr(this_arg);
12050         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12051         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
12052         void* handler_ptr = untag_ptr(handler);
12053         CHECK_ACCESS(handler_ptr);
12054         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
12055         if (handler_conv.free == LDKEventHandler_JCalls_free) {
12056                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12057                 LDKEventHandler_JCalls_cloned(&handler_conv);
12058         }
12059         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
12060 }
12061
12062 typedef struct LDKPersister_JCalls {
12063         atomic_size_t refcnt;
12064         JavaVM *vm;
12065         jweak o;
12066         jmethodID persist_manager_meth;
12067         jmethodID persist_graph_meth;
12068         jmethodID persist_scorer_meth;
12069 } LDKPersister_JCalls;
12070 static void LDKPersister_JCalls_free(void* this_arg) {
12071         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12072         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12073                 JNIEnv *env;
12074                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12075                 if (get_jenv_res == JNI_EDETACHED) {
12076                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12077                 } else {
12078                         DO_ASSERT(get_jenv_res == JNI_OK);
12079                 }
12080                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12081                 if (get_jenv_res == JNI_EDETACHED) {
12082                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12083                 }
12084                 FREE(j_calls);
12085         }
12086 }
12087 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
12088         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12089         JNIEnv *env;
12090         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12091         if (get_jenv_res == JNI_EDETACHED) {
12092                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12093         } else {
12094                 DO_ASSERT(get_jenv_res == JNI_OK);
12095         }
12096         LDKChannelManager channel_manager_var = *channel_manager;
12097         int64_t channel_manager_ref = 0;
12098         // WARNING: we may need a move here but no clone is available for LDKChannelManager
12099         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
12100         channel_manager_ref = tag_ptr(channel_manager_var.inner, channel_manager_var.is_owned);
12101         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12102         CHECK(obj != NULL);
12103         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
12104         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12105                 (*env)->ExceptionDescribe(env);
12106                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
12107         }
12108         void* ret_ptr = untag_ptr(ret);
12109         CHECK_ACCESS(ret_ptr);
12110         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
12111         FREE(untag_ptr(ret));
12112         if (get_jenv_res == JNI_EDETACHED) {
12113                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12114         }
12115         return ret_conv;
12116 }
12117 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
12118         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12119         JNIEnv *env;
12120         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12121         if (get_jenv_res == JNI_EDETACHED) {
12122                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12123         } else {
12124                 DO_ASSERT(get_jenv_res == JNI_OK);
12125         }
12126         LDKNetworkGraph network_graph_var = *network_graph;
12127         int64_t network_graph_ref = 0;
12128         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
12129         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
12130         network_graph_ref = tag_ptr(network_graph_var.inner, network_graph_var.is_owned);
12131         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12132         CHECK(obj != NULL);
12133         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
12134         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12135                 (*env)->ExceptionDescribe(env);
12136                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
12137         }
12138         void* ret_ptr = untag_ptr(ret);
12139         CHECK_ACCESS(ret_ptr);
12140         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
12141         FREE(untag_ptr(ret));
12142         if (get_jenv_res == JNI_EDETACHED) {
12143                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12144         }
12145         return ret_conv;
12146 }
12147 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKWriteableScore * scorer) {
12148         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12149         JNIEnv *env;
12150         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12151         if (get_jenv_res == JNI_EDETACHED) {
12152                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12153         } else {
12154                 DO_ASSERT(get_jenv_res == JNI_OK);
12155         }
12156         // WARNING: This object doesn't live past this scope, needs clone!
12157         int64_t ret_scorer = tag_ptr(scorer, false);
12158         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12159         CHECK(obj != NULL);
12160         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_scorer_meth, ret_scorer);
12161         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12162                 (*env)->ExceptionDescribe(env);
12163                 (*env)->FatalError(env, "A call to persist_scorer in LDKPersister from rust threw an exception.");
12164         }
12165         void* ret_ptr = untag_ptr(ret);
12166         CHECK_ACCESS(ret_ptr);
12167         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
12168         FREE(untag_ptr(ret));
12169         if (get_jenv_res == JNI_EDETACHED) {
12170                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12171         }
12172         return ret_conv;
12173 }
12174 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
12175         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
12176         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12177 }
12178 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
12179         jclass c = (*env)->GetObjectClass(env, o);
12180         CHECK(c != NULL);
12181         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
12182         atomic_init(&calls->refcnt, 1);
12183         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12184         calls->o = (*env)->NewWeakGlobalRef(env, o);
12185         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
12186         CHECK(calls->persist_manager_meth != NULL);
12187         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
12188         CHECK(calls->persist_graph_meth != NULL);
12189         calls->persist_scorer_meth = (*env)->GetMethodID(env, c, "persist_scorer", "(J)J");
12190         CHECK(calls->persist_scorer_meth != NULL);
12191
12192         LDKPersister ret = {
12193                 .this_arg = (void*) calls,
12194                 .persist_manager = persist_manager_LDKPersister_jcall,
12195                 .persist_graph = persist_graph_LDKPersister_jcall,
12196                 .persist_scorer = persist_scorer_LDKPersister_jcall,
12197                 .free = LDKPersister_JCalls_free,
12198         };
12199         return ret;
12200 }
12201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
12202         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
12203         *res_ptr = LDKPersister_init(env, clz, o);
12204         return tag_ptr(res_ptr, true);
12205 }
12206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
12207         void* this_arg_ptr = untag_ptr(this_arg);
12208         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12209         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
12210         LDKChannelManager channel_manager_conv;
12211         channel_manager_conv.inner = untag_ptr(channel_manager);
12212         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
12213         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
12214         channel_manager_conv.is_owned = false;
12215         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12216         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
12217         return tag_ptr(ret_conv, true);
12218 }
12219
12220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
12221         void* this_arg_ptr = untag_ptr(this_arg);
12222         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12223         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
12224         LDKNetworkGraph network_graph_conv;
12225         network_graph_conv.inner = untag_ptr(network_graph);
12226         network_graph_conv.is_owned = ptr_is_owned(network_graph);
12227         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
12228         network_graph_conv.is_owned = false;
12229         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12230         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
12231         return tag_ptr(ret_conv, true);
12232 }
12233
12234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1scorer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scorer) {
12235         void* this_arg_ptr = untag_ptr(this_arg);
12236         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12237         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
12238         void* scorer_ptr = untag_ptr(scorer);
12239         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
12240         LDKWriteableScore* scorer_conv = (LDKWriteableScore*)scorer_ptr;
12241         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12242         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, scorer_conv);
12243         return tag_ptr(ret_conv, true);
12244 }
12245
12246 typedef struct LDKFutureCallback_JCalls {
12247         atomic_size_t refcnt;
12248         JavaVM *vm;
12249         jweak o;
12250         jmethodID call_meth;
12251 } LDKFutureCallback_JCalls;
12252 static void LDKFutureCallback_JCalls_free(void* this_arg) {
12253         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
12254         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12255                 JNIEnv *env;
12256                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12257                 if (get_jenv_res == JNI_EDETACHED) {
12258                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12259                 } else {
12260                         DO_ASSERT(get_jenv_res == JNI_OK);
12261                 }
12262                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12263                 if (get_jenv_res == JNI_EDETACHED) {
12264                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12265                 }
12266                 FREE(j_calls);
12267         }
12268 }
12269 void call_LDKFutureCallback_jcall(const void* this_arg) {
12270         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_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         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12279         CHECK(obj != NULL);
12280         (*env)->CallVoidMethod(env, obj, j_calls->call_meth);
12281         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12282                 (*env)->ExceptionDescribe(env);
12283                 (*env)->FatalError(env, "A call to call in LDKFutureCallback from rust threw an exception.");
12284         }
12285         if (get_jenv_res == JNI_EDETACHED) {
12286                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12287         }
12288 }
12289 static void LDKFutureCallback_JCalls_cloned(LDKFutureCallback* new_obj) {
12290         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) new_obj->this_arg;
12291         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12292 }
12293 static inline LDKFutureCallback LDKFutureCallback_init (JNIEnv *env, jclass clz, jobject o) {
12294         jclass c = (*env)->GetObjectClass(env, o);
12295         CHECK(c != NULL);
12296         LDKFutureCallback_JCalls *calls = MALLOC(sizeof(LDKFutureCallback_JCalls), "LDKFutureCallback_JCalls");
12297         atomic_init(&calls->refcnt, 1);
12298         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12299         calls->o = (*env)->NewWeakGlobalRef(env, o);
12300         calls->call_meth = (*env)->GetMethodID(env, c, "call", "()V");
12301         CHECK(calls->call_meth != NULL);
12302
12303         LDKFutureCallback ret = {
12304                 .this_arg = (void*) calls,
12305                 .call = call_LDKFutureCallback_jcall,
12306                 .free = LDKFutureCallback_JCalls_free,
12307         };
12308         return ret;
12309 }
12310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFutureCallback_1new(JNIEnv *env, jclass clz, jobject o) {
12311         LDKFutureCallback *res_ptr = MALLOC(sizeof(LDKFutureCallback), "LDKFutureCallback");
12312         *res_ptr = LDKFutureCallback_init(env, clz, o);
12313         return tag_ptr(res_ptr, true);
12314 }
12315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1call(JNIEnv *env, jclass clz, int64_t this_arg) {
12316         void* this_arg_ptr = untag_ptr(this_arg);
12317         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12318         LDKFutureCallback* this_arg_conv = (LDKFutureCallback*)this_arg_ptr;
12319         (this_arg_conv->call)(this_arg_conv->this_arg);
12320 }
12321
12322 typedef struct LDKListen_JCalls {
12323         atomic_size_t refcnt;
12324         JavaVM *vm;
12325         jweak o;
12326         jmethodID filtered_block_connected_meth;
12327         jmethodID block_connected_meth;
12328         jmethodID block_disconnected_meth;
12329 } LDKListen_JCalls;
12330 static void LDKListen_JCalls_free(void* this_arg) {
12331         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12332         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12333                 JNIEnv *env;
12334                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12335                 if (get_jenv_res == JNI_EDETACHED) {
12336                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12337                 } else {
12338                         DO_ASSERT(get_jenv_res == JNI_OK);
12339                 }
12340                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12341                 if (get_jenv_res == JNI_EDETACHED) {
12342                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12343                 }
12344                 FREE(j_calls);
12345         }
12346 }
12347 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
12348         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12349         JNIEnv *env;
12350         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12351         if (get_jenv_res == JNI_EDETACHED) {
12352                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12353         } else {
12354                 DO_ASSERT(get_jenv_res == JNI_OK);
12355         }
12356         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
12357         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
12358         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
12359         int64_tArray txdata_arr = NULL;
12360         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
12361         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
12362         for (size_t c = 0; c < txdata_var.datalen; c++) {
12363                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12364                 *txdata_conv_28_conv = txdata_var.data[c];
12365                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
12366         }
12367         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
12368         FREE(txdata_var.data);
12369         int32_t height_conv = height;
12370         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12371         CHECK(obj != NULL);
12372         (*env)->CallVoidMethod(env, obj, j_calls->filtered_block_connected_meth, header_arr, txdata_arr, height_conv);
12373         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12374                 (*env)->ExceptionDescribe(env);
12375                 (*env)->FatalError(env, "A call to filtered_block_connected in LDKListen from rust threw an exception.");
12376         }
12377         if (get_jenv_res == JNI_EDETACHED) {
12378                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12379         }
12380 }
12381 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
12382         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12383         JNIEnv *env;
12384         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12385         if (get_jenv_res == JNI_EDETACHED) {
12386                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12387         } else {
12388                 DO_ASSERT(get_jenv_res == JNI_OK);
12389         }
12390         LDKu8slice block_var = block;
12391         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
12392         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
12393         int32_t height_conv = height;
12394         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12395         CHECK(obj != NULL);
12396         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
12397         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12398                 (*env)->ExceptionDescribe(env);
12399                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
12400         }
12401         if (get_jenv_res == JNI_EDETACHED) {
12402                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12403         }
12404 }
12405 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
12406         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12407         JNIEnv *env;
12408         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12409         if (get_jenv_res == JNI_EDETACHED) {
12410                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12411         } else {
12412                 DO_ASSERT(get_jenv_res == JNI_OK);
12413         }
12414         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
12415         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
12416         int32_t height_conv = height;
12417         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12418         CHECK(obj != NULL);
12419         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
12420         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12421                 (*env)->ExceptionDescribe(env);
12422                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
12423         }
12424         if (get_jenv_res == JNI_EDETACHED) {
12425                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12426         }
12427 }
12428 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
12429         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
12430         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12431 }
12432 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
12433         jclass c = (*env)->GetObjectClass(env, o);
12434         CHECK(c != NULL);
12435         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
12436         atomic_init(&calls->refcnt, 1);
12437         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12438         calls->o = (*env)->NewWeakGlobalRef(env, o);
12439         calls->filtered_block_connected_meth = (*env)->GetMethodID(env, c, "filtered_block_connected", "([B[JI)V");
12440         CHECK(calls->filtered_block_connected_meth != NULL);
12441         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
12442         CHECK(calls->block_connected_meth != NULL);
12443         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
12444         CHECK(calls->block_disconnected_meth != NULL);
12445
12446         LDKListen ret = {
12447                 .this_arg = (void*) calls,
12448                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
12449                 .block_connected = block_connected_LDKListen_jcall,
12450                 .block_disconnected = block_disconnected_LDKListen_jcall,
12451                 .free = LDKListen_JCalls_free,
12452         };
12453         return ret;
12454 }
12455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
12456         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
12457         *res_ptr = LDKListen_init(env, clz, o);
12458         return tag_ptr(res_ptr, true);
12459 }
12460 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) {
12461         void* this_arg_ptr = untag_ptr(this_arg);
12462         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12463         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
12464         uint8_t header_arr[80];
12465         CHECK((*env)->GetArrayLength(env, header) == 80);
12466         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12467         uint8_t (*header_ref)[80] = &header_arr;
12468         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12469         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
12470         if (txdata_constr.datalen > 0)
12471                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12472         else
12473                 txdata_constr.data = NULL;
12474         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
12475         for (size_t c = 0; c < txdata_constr.datalen; c++) {
12476                 int64_t txdata_conv_28 = txdata_vals[c];
12477                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
12478                 CHECK_ACCESS(txdata_conv_28_ptr);
12479                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
12480                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
12481                 txdata_constr.data[c] = txdata_conv_28_conv;
12482         }
12483         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
12484         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
12485 }
12486
12487 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) {
12488         void* this_arg_ptr = untag_ptr(this_arg);
12489         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12490         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
12491         LDKu8slice block_ref;
12492         block_ref.datalen = (*env)->GetArrayLength(env, block);
12493         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
12494         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
12495         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
12496 }
12497
12498 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) {
12499         void* this_arg_ptr = untag_ptr(this_arg);
12500         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12501         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
12502         uint8_t header_arr[80];
12503         CHECK((*env)->GetArrayLength(env, header) == 80);
12504         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12505         uint8_t (*header_ref)[80] = &header_arr;
12506         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
12507 }
12508
12509 typedef struct LDKConfirm_JCalls {
12510         atomic_size_t refcnt;
12511         JavaVM *vm;
12512         jweak o;
12513         jmethodID transactions_confirmed_meth;
12514         jmethodID transaction_unconfirmed_meth;
12515         jmethodID best_block_updated_meth;
12516         jmethodID get_relevant_txids_meth;
12517 } LDKConfirm_JCalls;
12518 static void LDKConfirm_JCalls_free(void* this_arg) {
12519         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12520         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12521                 JNIEnv *env;
12522                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12523                 if (get_jenv_res == JNI_EDETACHED) {
12524                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12525                 } else {
12526                         DO_ASSERT(get_jenv_res == JNI_OK);
12527                 }
12528                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12529                 if (get_jenv_res == JNI_EDETACHED) {
12530                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12531                 }
12532                 FREE(j_calls);
12533         }
12534 }
12535 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
12536         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12537         JNIEnv *env;
12538         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12539         if (get_jenv_res == JNI_EDETACHED) {
12540                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12541         } else {
12542                 DO_ASSERT(get_jenv_res == JNI_OK);
12543         }
12544         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
12545         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
12546         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
12547         int64_tArray txdata_arr = NULL;
12548         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
12549         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
12550         for (size_t c = 0; c < txdata_var.datalen; c++) {
12551                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12552                 *txdata_conv_28_conv = txdata_var.data[c];
12553                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
12554         }
12555         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
12556         FREE(txdata_var.data);
12557         int32_t height_conv = height;
12558         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12559         CHECK(obj != NULL);
12560         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
12561         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12562                 (*env)->ExceptionDescribe(env);
12563                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
12564         }
12565         if (get_jenv_res == JNI_EDETACHED) {
12566                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12567         }
12568 }
12569 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
12570         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12571         JNIEnv *env;
12572         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12573         if (get_jenv_res == JNI_EDETACHED) {
12574                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12575         } else {
12576                 DO_ASSERT(get_jenv_res == JNI_OK);
12577         }
12578         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
12579         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
12580         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12581         CHECK(obj != NULL);
12582         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
12583         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12584                 (*env)->ExceptionDescribe(env);
12585                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
12586         }
12587         if (get_jenv_res == JNI_EDETACHED) {
12588                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12589         }
12590 }
12591 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
12592         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12593         JNIEnv *env;
12594         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12595         if (get_jenv_res == JNI_EDETACHED) {
12596                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12597         } else {
12598                 DO_ASSERT(get_jenv_res == JNI_OK);
12599         }
12600         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
12601         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
12602         int32_t height_conv = height;
12603         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12604         CHECK(obj != NULL);
12605         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
12606         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12607                 (*env)->ExceptionDescribe(env);
12608                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
12609         }
12610         if (get_jenv_res == JNI_EDETACHED) {
12611                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12612         }
12613 }
12614 LDKCVec_C2Tuple_TxidBlockHashZZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
12615         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12616         JNIEnv *env;
12617         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12618         if (get_jenv_res == JNI_EDETACHED) {
12619                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12620         } else {
12621                 DO_ASSERT(get_jenv_res == JNI_OK);
12622         }
12623         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12624         CHECK(obj != NULL);
12625         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
12626         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12627                 (*env)->ExceptionDescribe(env);
12628                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
12629         }
12630         LDKCVec_C2Tuple_TxidBlockHashZZ ret_constr;
12631         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12632         if (ret_constr.datalen > 0)
12633                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKCVec_C2Tuple_TxidBlockHashZZ Elements");
12634         else
12635                 ret_constr.data = NULL;
12636         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12637         for (size_t z = 0; z < ret_constr.datalen; z++) {
12638                 int64_t ret_conv_25 = ret_vals[z];
12639                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
12640                 CHECK_ACCESS(ret_conv_25_ptr);
12641                 LDKC2Tuple_TxidBlockHashZ ret_conv_25_conv = *(LDKC2Tuple_TxidBlockHashZ*)(ret_conv_25_ptr);
12642                 FREE(untag_ptr(ret_conv_25));
12643                 ret_constr.data[z] = ret_conv_25_conv;
12644         }
12645         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12646         if (get_jenv_res == JNI_EDETACHED) {
12647                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12648         }
12649         return ret_constr;
12650 }
12651 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
12652         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
12653         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12654 }
12655 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
12656         jclass c = (*env)->GetObjectClass(env, o);
12657         CHECK(c != NULL);
12658         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
12659         atomic_init(&calls->refcnt, 1);
12660         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12661         calls->o = (*env)->NewWeakGlobalRef(env, o);
12662         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
12663         CHECK(calls->transactions_confirmed_meth != NULL);
12664         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
12665         CHECK(calls->transaction_unconfirmed_meth != NULL);
12666         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
12667         CHECK(calls->best_block_updated_meth != NULL);
12668         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[J");
12669         CHECK(calls->get_relevant_txids_meth != NULL);
12670
12671         LDKConfirm ret = {
12672                 .this_arg = (void*) calls,
12673                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
12674                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
12675                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
12676                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
12677                 .free = LDKConfirm_JCalls_free,
12678         };
12679         return ret;
12680 }
12681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
12682         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
12683         *res_ptr = LDKConfirm_init(env, clz, o);
12684         return tag_ptr(res_ptr, true);
12685 }
12686 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) {
12687         void* this_arg_ptr = untag_ptr(this_arg);
12688         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12689         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12690         uint8_t header_arr[80];
12691         CHECK((*env)->GetArrayLength(env, header) == 80);
12692         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12693         uint8_t (*header_ref)[80] = &header_arr;
12694         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12695         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
12696         if (txdata_constr.datalen > 0)
12697                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12698         else
12699                 txdata_constr.data = NULL;
12700         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
12701         for (size_t c = 0; c < txdata_constr.datalen; c++) {
12702                 int64_t txdata_conv_28 = txdata_vals[c];
12703                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
12704                 CHECK_ACCESS(txdata_conv_28_ptr);
12705                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
12706                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
12707                 txdata_constr.data[c] = txdata_conv_28_conv;
12708         }
12709         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
12710         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
12711 }
12712
12713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
12714         void* this_arg_ptr = untag_ptr(this_arg);
12715         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12716         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12717         uint8_t txid_arr[32];
12718         CHECK((*env)->GetArrayLength(env, txid) == 32);
12719         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
12720         uint8_t (*txid_ref)[32] = &txid_arr;
12721         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
12722 }
12723
12724 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) {
12725         void* this_arg_ptr = untag_ptr(this_arg);
12726         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12727         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12728         uint8_t header_arr[80];
12729         CHECK((*env)->GetArrayLength(env, header) == 80);
12730         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12731         uint8_t (*header_ref)[80] = &header_arr;
12732         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
12733 }
12734
12735 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
12736         void* this_arg_ptr = untag_ptr(this_arg);
12737         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12738         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12739         LDKCVec_C2Tuple_TxidBlockHashZZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
12740         int64_tArray ret_arr = NULL;
12741         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12742         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12743         for (size_t z = 0; z < ret_var.datalen; z++) {
12744                 LDKC2Tuple_TxidBlockHashZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
12745                 *ret_conv_25_conv = ret_var.data[z];
12746                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
12747         }
12748         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12749         FREE(ret_var.data);
12750         return ret_arr;
12751 }
12752
12753 typedef struct LDKPersist_JCalls {
12754         atomic_size_t refcnt;
12755         JavaVM *vm;
12756         jweak o;
12757         jmethodID persist_new_channel_meth;
12758         jmethodID update_persisted_channel_meth;
12759 } LDKPersist_JCalls;
12760 static void LDKPersist_JCalls_free(void* this_arg) {
12761         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
12762         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12763                 JNIEnv *env;
12764                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12765                 if (get_jenv_res == JNI_EDETACHED) {
12766                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12767                 } else {
12768                         DO_ASSERT(get_jenv_res == JNI_OK);
12769                 }
12770                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12771                 if (get_jenv_res == JNI_EDETACHED) {
12772                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12773                 }
12774                 FREE(j_calls);
12775         }
12776 }
12777 LDKChannelMonitorUpdateStatus persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
12778         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
12779         JNIEnv *env;
12780         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12781         if (get_jenv_res == JNI_EDETACHED) {
12782                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12783         } else {
12784                 DO_ASSERT(get_jenv_res == JNI_OK);
12785         }
12786         LDKOutPoint channel_id_var = channel_id;
12787         int64_t channel_id_ref = 0;
12788         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
12789         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
12790         LDKChannelMonitor data_var = *data;
12791         int64_t data_ref = 0;
12792         data_var = ChannelMonitor_clone(&data_var);
12793         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
12794         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
12795         LDKMonitorUpdateId update_id_var = update_id;
12796         int64_t update_id_ref = 0;
12797         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
12798         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
12799         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12800         CHECK(obj != NULL);
12801         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
12802         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12803                 (*env)->ExceptionDescribe(env);
12804                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
12805         }
12806         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
12807         if (get_jenv_res == JNI_EDETACHED) {
12808                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12809         }
12810         return ret_conv;
12811 }
12812 LDKChannelMonitorUpdateStatus update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, LDKChannelMonitorUpdate update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
12813         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
12814         JNIEnv *env;
12815         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12816         if (get_jenv_res == JNI_EDETACHED) {
12817                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12818         } else {
12819                 DO_ASSERT(get_jenv_res == JNI_OK);
12820         }
12821         LDKOutPoint channel_id_var = channel_id;
12822         int64_t channel_id_ref = 0;
12823         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
12824         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
12825         LDKChannelMonitorUpdate update_var = update;
12826         int64_t update_ref = 0;
12827         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
12828         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
12829         LDKChannelMonitor data_var = *data;
12830         int64_t data_ref = 0;
12831         data_var = ChannelMonitor_clone(&data_var);
12832         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
12833         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
12834         LDKMonitorUpdateId update_id_var = update_id;
12835         int64_t update_id_ref = 0;
12836         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
12837         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
12838         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12839         CHECK(obj != NULL);
12840         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
12841         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12842                 (*env)->ExceptionDescribe(env);
12843                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
12844         }
12845         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
12846         if (get_jenv_res == JNI_EDETACHED) {
12847                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12848         }
12849         return ret_conv;
12850 }
12851 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
12852         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
12853         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12854 }
12855 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
12856         jclass c = (*env)->GetObjectClass(env, o);
12857         CHECK(c != NULL);
12858         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
12859         atomic_init(&calls->refcnt, 1);
12860         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12861         calls->o = (*env)->NewWeakGlobalRef(env, o);
12862         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
12863         CHECK(calls->persist_new_channel_meth != NULL);
12864         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
12865         CHECK(calls->update_persisted_channel_meth != NULL);
12866
12867         LDKPersist ret = {
12868                 .this_arg = (void*) calls,
12869                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
12870                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
12871                 .free = LDKPersist_JCalls_free,
12872         };
12873         return ret;
12874 }
12875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
12876         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
12877         *res_ptr = LDKPersist_init(env, clz, o);
12878         return tag_ptr(res_ptr, true);
12879 }
12880 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) {
12881         void* this_arg_ptr = untag_ptr(this_arg);
12882         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12883         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
12884         LDKOutPoint channel_id_conv;
12885         channel_id_conv.inner = untag_ptr(channel_id);
12886         channel_id_conv.is_owned = ptr_is_owned(channel_id);
12887         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
12888         channel_id_conv = OutPoint_clone(&channel_id_conv);
12889         LDKChannelMonitor data_conv;
12890         data_conv.inner = untag_ptr(data);
12891         data_conv.is_owned = ptr_is_owned(data);
12892         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
12893         data_conv.is_owned = false;
12894         LDKMonitorUpdateId update_id_conv;
12895         update_id_conv.inner = untag_ptr(update_id);
12896         update_id_conv.is_owned = ptr_is_owned(update_id);
12897         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
12898         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
12899         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));
12900         return ret_conv;
12901 }
12902
12903 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) {
12904         void* this_arg_ptr = untag_ptr(this_arg);
12905         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12906         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
12907         LDKOutPoint channel_id_conv;
12908         channel_id_conv.inner = untag_ptr(channel_id);
12909         channel_id_conv.is_owned = ptr_is_owned(channel_id);
12910         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
12911         channel_id_conv = OutPoint_clone(&channel_id_conv);
12912         LDKChannelMonitorUpdate update_conv;
12913         update_conv.inner = untag_ptr(update);
12914         update_conv.is_owned = ptr_is_owned(update);
12915         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
12916         update_conv = ChannelMonitorUpdate_clone(&update_conv);
12917         LDKChannelMonitor data_conv;
12918         data_conv.inner = untag_ptr(data);
12919         data_conv.is_owned = ptr_is_owned(data);
12920         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
12921         data_conv.is_owned = false;
12922         LDKMonitorUpdateId update_id_conv;
12923         update_id_conv.inner = untag_ptr(update_id);
12924         update_id_conv.is_owned = ptr_is_owned(update_id);
12925         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
12926         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
12927         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));
12928         return ret_conv;
12929 }
12930
12931 static jclass LDKRetry_Attempts_class = NULL;
12932 static jmethodID LDKRetry_Attempts_meth = NULL;
12933 static jclass LDKRetry_Timeout_class = NULL;
12934 static jmethodID LDKRetry_Timeout_meth = NULL;
12935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRetry_init (JNIEnv *env, jclass clz) {
12936         LDKRetry_Attempts_class =
12937                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Attempts"));
12938         CHECK(LDKRetry_Attempts_class != NULL);
12939         LDKRetry_Attempts_meth = (*env)->GetMethodID(env, LDKRetry_Attempts_class, "<init>", "(J)V");
12940         CHECK(LDKRetry_Attempts_meth != NULL);
12941         LDKRetry_Timeout_class =
12942                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Timeout"));
12943         CHECK(LDKRetry_Timeout_class != NULL);
12944         LDKRetry_Timeout_meth = (*env)->GetMethodID(env, LDKRetry_Timeout_class, "<init>", "(J)V");
12945         CHECK(LDKRetry_Timeout_meth != NULL);
12946 }
12947 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRetry_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
12948         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
12949         switch(obj->tag) {
12950                 case LDKRetry_Attempts: {
12951                         int64_t attempts_conv = obj->attempts;
12952                         return (*env)->NewObject(env, LDKRetry_Attempts_class, LDKRetry_Attempts_meth, attempts_conv);
12953                 }
12954                 case LDKRetry_Timeout: {
12955                         int64_t timeout_conv = obj->timeout;
12956                         return (*env)->NewObject(env, LDKRetry_Timeout_class, LDKRetry_Timeout_meth, timeout_conv);
12957                 }
12958                 default: abort();
12959         }
12960 }
12961 typedef struct LDKChannelMessageHandler_JCalls {
12962         atomic_size_t refcnt;
12963         JavaVM *vm;
12964         jweak o;
12965         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
12966         jmethodID handle_open_channel_meth;
12967         jmethodID handle_accept_channel_meth;
12968         jmethodID handle_funding_created_meth;
12969         jmethodID handle_funding_signed_meth;
12970         jmethodID handle_channel_ready_meth;
12971         jmethodID handle_shutdown_meth;
12972         jmethodID handle_closing_signed_meth;
12973         jmethodID handle_update_add_htlc_meth;
12974         jmethodID handle_update_fulfill_htlc_meth;
12975         jmethodID handle_update_fail_htlc_meth;
12976         jmethodID handle_update_fail_malformed_htlc_meth;
12977         jmethodID handle_commitment_signed_meth;
12978         jmethodID handle_revoke_and_ack_meth;
12979         jmethodID handle_update_fee_meth;
12980         jmethodID handle_announcement_signatures_meth;
12981         jmethodID peer_disconnected_meth;
12982         jmethodID peer_connected_meth;
12983         jmethodID handle_channel_reestablish_meth;
12984         jmethodID handle_channel_update_meth;
12985         jmethodID handle_error_meth;
12986         jmethodID provided_node_features_meth;
12987         jmethodID provided_init_features_meth;
12988 } LDKChannelMessageHandler_JCalls;
12989 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
12990         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12991         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12992                 JNIEnv *env;
12993                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12994                 if (get_jenv_res == JNI_EDETACHED) {
12995                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12996                 } else {
12997                         DO_ASSERT(get_jenv_res == JNI_OK);
12998                 }
12999                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13000                 if (get_jenv_res == JNI_EDETACHED) {
13001                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13002                 }
13003                 FREE(j_calls);
13004         }
13005 }
13006 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKOpenChannel * msg) {
13007         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13008         JNIEnv *env;
13009         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13010         if (get_jenv_res == JNI_EDETACHED) {
13011                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13012         } else {
13013                 DO_ASSERT(get_jenv_res == JNI_OK);
13014         }
13015         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13016         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13017         LDKOpenChannel msg_var = *msg;
13018         int64_t msg_ref = 0;
13019         msg_var = OpenChannel_clone(&msg_var);
13020         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13021         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13022         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13023         CHECK(obj != NULL);
13024         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, msg_ref);
13025         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13026                 (*env)->ExceptionDescribe(env);
13027                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
13028         }
13029         if (get_jenv_res == JNI_EDETACHED) {
13030                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13031         }
13032 }
13033 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAcceptChannel * msg) {
13034         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13035         JNIEnv *env;
13036         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13037         if (get_jenv_res == JNI_EDETACHED) {
13038                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13039         } else {
13040                 DO_ASSERT(get_jenv_res == JNI_OK);
13041         }
13042         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13043         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13044         LDKAcceptChannel msg_var = *msg;
13045         int64_t msg_ref = 0;
13046         msg_var = AcceptChannel_clone(&msg_var);
13047         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13048         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13049         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13050         CHECK(obj != NULL);
13051         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, msg_ref);
13052         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13053                 (*env)->ExceptionDescribe(env);
13054                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
13055         }
13056         if (get_jenv_res == JNI_EDETACHED) {
13057                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13058         }
13059 }
13060 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
13061         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13062         JNIEnv *env;
13063         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13064         if (get_jenv_res == JNI_EDETACHED) {
13065                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13066         } else {
13067                 DO_ASSERT(get_jenv_res == JNI_OK);
13068         }
13069         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13070         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13071         LDKFundingCreated msg_var = *msg;
13072         int64_t msg_ref = 0;
13073         msg_var = FundingCreated_clone(&msg_var);
13074         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13075         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13076         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13077         CHECK(obj != NULL);
13078         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
13079         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13080                 (*env)->ExceptionDescribe(env);
13081                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
13082         }
13083         if (get_jenv_res == JNI_EDETACHED) {
13084                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13085         }
13086 }
13087 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
13088         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13089         JNIEnv *env;
13090         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13091         if (get_jenv_res == JNI_EDETACHED) {
13092                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13093         } else {
13094                 DO_ASSERT(get_jenv_res == JNI_OK);
13095         }
13096         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13097         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13098         LDKFundingSigned msg_var = *msg;
13099         int64_t msg_ref = 0;
13100         msg_var = FundingSigned_clone(&msg_var);
13101         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13102         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13103         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13104         CHECK(obj != NULL);
13105         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
13106         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13107                 (*env)->ExceptionDescribe(env);
13108                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
13109         }
13110         if (get_jenv_res == JNI_EDETACHED) {
13111                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13112         }
13113 }
13114 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
13115         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13116         JNIEnv *env;
13117         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13118         if (get_jenv_res == JNI_EDETACHED) {
13119                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13120         } else {
13121                 DO_ASSERT(get_jenv_res == JNI_OK);
13122         }
13123         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13124         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13125         LDKChannelReady msg_var = *msg;
13126         int64_t msg_ref = 0;
13127         msg_var = ChannelReady_clone(&msg_var);
13128         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13129         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13130         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13131         CHECK(obj != NULL);
13132         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_ready_meth, their_node_id_arr, msg_ref);
13133         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13134                 (*env)->ExceptionDescribe(env);
13135                 (*env)->FatalError(env, "A call to handle_channel_ready in LDKChannelMessageHandler from rust threw an exception.");
13136         }
13137         if (get_jenv_res == JNI_EDETACHED) {
13138                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13139         }
13140 }
13141 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown * msg) {
13142         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13143         JNIEnv *env;
13144         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13145         if (get_jenv_res == JNI_EDETACHED) {
13146                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13147         } else {
13148                 DO_ASSERT(get_jenv_res == JNI_OK);
13149         }
13150         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13151         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13152         LDKShutdown msg_var = *msg;
13153         int64_t msg_ref = 0;
13154         msg_var = Shutdown_clone(&msg_var);
13155         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13156         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13157         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13158         CHECK(obj != NULL);
13159         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, msg_ref);
13160         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13161                 (*env)->ExceptionDescribe(env);
13162                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
13163         }
13164         if (get_jenv_res == JNI_EDETACHED) {
13165                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13166         }
13167 }
13168 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
13169         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13170         JNIEnv *env;
13171         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13172         if (get_jenv_res == JNI_EDETACHED) {
13173                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13174         } else {
13175                 DO_ASSERT(get_jenv_res == JNI_OK);
13176         }
13177         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13178         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13179         LDKClosingSigned msg_var = *msg;
13180         int64_t msg_ref = 0;
13181         msg_var = ClosingSigned_clone(&msg_var);
13182         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13183         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13184         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13185         CHECK(obj != NULL);
13186         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
13187         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13188                 (*env)->ExceptionDescribe(env);
13189                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
13190         }
13191         if (get_jenv_res == JNI_EDETACHED) {
13192                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13193         }
13194 }
13195 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
13196         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13197         JNIEnv *env;
13198         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13199         if (get_jenv_res == JNI_EDETACHED) {
13200                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13201         } else {
13202                 DO_ASSERT(get_jenv_res == JNI_OK);
13203         }
13204         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13205         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13206         LDKUpdateAddHTLC msg_var = *msg;
13207         int64_t msg_ref = 0;
13208         msg_var = UpdateAddHTLC_clone(&msg_var);
13209         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13210         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13211         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13212         CHECK(obj != NULL);
13213         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
13214         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13215                 (*env)->ExceptionDescribe(env);
13216                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
13217         }
13218         if (get_jenv_res == JNI_EDETACHED) {
13219                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13220         }
13221 }
13222 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
13223         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13224         JNIEnv *env;
13225         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13226         if (get_jenv_res == JNI_EDETACHED) {
13227                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13228         } else {
13229                 DO_ASSERT(get_jenv_res == JNI_OK);
13230         }
13231         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13232         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13233         LDKUpdateFulfillHTLC msg_var = *msg;
13234         int64_t msg_ref = 0;
13235         msg_var = UpdateFulfillHTLC_clone(&msg_var);
13236         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13237         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13238         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13239         CHECK(obj != NULL);
13240         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
13241         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13242                 (*env)->ExceptionDescribe(env);
13243                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
13244         }
13245         if (get_jenv_res == JNI_EDETACHED) {
13246                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13247         }
13248 }
13249 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
13250         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13251         JNIEnv *env;
13252         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13253         if (get_jenv_res == JNI_EDETACHED) {
13254                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13255         } else {
13256                 DO_ASSERT(get_jenv_res == JNI_OK);
13257         }
13258         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13259         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13260         LDKUpdateFailHTLC msg_var = *msg;
13261         int64_t msg_ref = 0;
13262         msg_var = UpdateFailHTLC_clone(&msg_var);
13263         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13264         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13265         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13266         CHECK(obj != NULL);
13267         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
13268         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13269                 (*env)->ExceptionDescribe(env);
13270                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
13271         }
13272         if (get_jenv_res == JNI_EDETACHED) {
13273                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13274         }
13275 }
13276 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
13277         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13278         JNIEnv *env;
13279         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13280         if (get_jenv_res == JNI_EDETACHED) {
13281                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13282         } else {
13283                 DO_ASSERT(get_jenv_res == JNI_OK);
13284         }
13285         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13286         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13287         LDKUpdateFailMalformedHTLC msg_var = *msg;
13288         int64_t msg_ref = 0;
13289         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
13290         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13291         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13292         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13293         CHECK(obj != NULL);
13294         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
13295         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13296                 (*env)->ExceptionDescribe(env);
13297                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
13298         }
13299         if (get_jenv_res == JNI_EDETACHED) {
13300                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13301         }
13302 }
13303 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
13304         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13305         JNIEnv *env;
13306         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13307         if (get_jenv_res == JNI_EDETACHED) {
13308                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13309         } else {
13310                 DO_ASSERT(get_jenv_res == JNI_OK);
13311         }
13312         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13313         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13314         LDKCommitmentSigned msg_var = *msg;
13315         int64_t msg_ref = 0;
13316         msg_var = CommitmentSigned_clone(&msg_var);
13317         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13318         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13319         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13320         CHECK(obj != NULL);
13321         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
13322         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13323                 (*env)->ExceptionDescribe(env);
13324                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
13325         }
13326         if (get_jenv_res == JNI_EDETACHED) {
13327                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13328         }
13329 }
13330 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
13331         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13332         JNIEnv *env;
13333         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13334         if (get_jenv_res == JNI_EDETACHED) {
13335                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13336         } else {
13337                 DO_ASSERT(get_jenv_res == JNI_OK);
13338         }
13339         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13340         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13341         LDKRevokeAndACK msg_var = *msg;
13342         int64_t msg_ref = 0;
13343         msg_var = RevokeAndACK_clone(&msg_var);
13344         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13345         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13346         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13347         CHECK(obj != NULL);
13348         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
13349         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13350                 (*env)->ExceptionDescribe(env);
13351                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
13352         }
13353         if (get_jenv_res == JNI_EDETACHED) {
13354                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13355         }
13356 }
13357 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
13358         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13359         JNIEnv *env;
13360         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13361         if (get_jenv_res == JNI_EDETACHED) {
13362                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13363         } else {
13364                 DO_ASSERT(get_jenv_res == JNI_OK);
13365         }
13366         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13367         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13368         LDKUpdateFee msg_var = *msg;
13369         int64_t msg_ref = 0;
13370         msg_var = UpdateFee_clone(&msg_var);
13371         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13372         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13373         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13374         CHECK(obj != NULL);
13375         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
13376         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13377                 (*env)->ExceptionDescribe(env);
13378                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
13379         }
13380         if (get_jenv_res == JNI_EDETACHED) {
13381                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13382         }
13383 }
13384 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
13385         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13386         JNIEnv *env;
13387         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13388         if (get_jenv_res == JNI_EDETACHED) {
13389                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13390         } else {
13391                 DO_ASSERT(get_jenv_res == JNI_OK);
13392         }
13393         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13394         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13395         LDKAnnouncementSignatures msg_var = *msg;
13396         int64_t msg_ref = 0;
13397         msg_var = AnnouncementSignatures_clone(&msg_var);
13398         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13399         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13400         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13401         CHECK(obj != NULL);
13402         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
13403         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13404                 (*env)->ExceptionDescribe(env);
13405                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
13406         }
13407         if (get_jenv_res == JNI_EDETACHED) {
13408                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13409         }
13410 }
13411 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13412         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13413         JNIEnv *env;
13414         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13415         if (get_jenv_res == JNI_EDETACHED) {
13416                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13417         } else {
13418                 DO_ASSERT(get_jenv_res == JNI_OK);
13419         }
13420         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13421         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13422         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13423         CHECK(obj != NULL);
13424         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr);
13425         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13426                 (*env)->ExceptionDescribe(env);
13427                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
13428         }
13429         if (get_jenv_res == JNI_EDETACHED) {
13430                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13431         }
13432 }
13433 LDKCResult_NoneNoneZ peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg, bool inbound) {
13434         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13435         JNIEnv *env;
13436         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13437         if (get_jenv_res == JNI_EDETACHED) {
13438                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13439         } else {
13440                 DO_ASSERT(get_jenv_res == JNI_OK);
13441         }
13442         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13443         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13444         LDKInit msg_var = *msg;
13445         int64_t msg_ref = 0;
13446         msg_var = Init_clone(&msg_var);
13447         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13448         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13449         jboolean inbound_conv = inbound;
13450         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13451         CHECK(obj != NULL);
13452         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref, inbound_conv);
13453         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13454                 (*env)->ExceptionDescribe(env);
13455                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
13456         }
13457         void* ret_ptr = untag_ptr(ret);
13458         CHECK_ACCESS(ret_ptr);
13459         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
13460         FREE(untag_ptr(ret));
13461         if (get_jenv_res == JNI_EDETACHED) {
13462                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13463         }
13464         return ret_conv;
13465 }
13466 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
13467         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13468         JNIEnv *env;
13469         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13470         if (get_jenv_res == JNI_EDETACHED) {
13471                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13472         } else {
13473                 DO_ASSERT(get_jenv_res == JNI_OK);
13474         }
13475         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13476         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13477         LDKChannelReestablish msg_var = *msg;
13478         int64_t msg_ref = 0;
13479         msg_var = ChannelReestablish_clone(&msg_var);
13480         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13481         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13482         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13483         CHECK(obj != NULL);
13484         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
13485         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13486                 (*env)->ExceptionDescribe(env);
13487                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
13488         }
13489         if (get_jenv_res == JNI_EDETACHED) {
13490                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13491         }
13492 }
13493 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
13494         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13495         JNIEnv *env;
13496         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13497         if (get_jenv_res == JNI_EDETACHED) {
13498                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13499         } else {
13500                 DO_ASSERT(get_jenv_res == JNI_OK);
13501         }
13502         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13503         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13504         LDKChannelUpdate msg_var = *msg;
13505         int64_t msg_ref = 0;
13506         msg_var = ChannelUpdate_clone(&msg_var);
13507         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13508         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13509         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13510         CHECK(obj != NULL);
13511         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
13512         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13513                 (*env)->ExceptionDescribe(env);
13514                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
13515         }
13516         if (get_jenv_res == JNI_EDETACHED) {
13517                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13518         }
13519 }
13520 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
13521         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13522         JNIEnv *env;
13523         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13524         if (get_jenv_res == JNI_EDETACHED) {
13525                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13526         } else {
13527                 DO_ASSERT(get_jenv_res == JNI_OK);
13528         }
13529         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13530         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13531         LDKErrorMessage msg_var = *msg;
13532         int64_t msg_ref = 0;
13533         msg_var = ErrorMessage_clone(&msg_var);
13534         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13535         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13536         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13537         CHECK(obj != NULL);
13538         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
13539         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13540                 (*env)->ExceptionDescribe(env);
13541                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
13542         }
13543         if (get_jenv_res == JNI_EDETACHED) {
13544                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13545         }
13546 }
13547 LDKNodeFeatures provided_node_features_LDKChannelMessageHandler_jcall(const void* this_arg) {
13548         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13549         JNIEnv *env;
13550         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13551         if (get_jenv_res == JNI_EDETACHED) {
13552                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13553         } else {
13554                 DO_ASSERT(get_jenv_res == JNI_OK);
13555         }
13556         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13557         CHECK(obj != NULL);
13558         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
13559         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13560                 (*env)->ExceptionDescribe(env);
13561                 (*env)->FatalError(env, "A call to provided_node_features in LDKChannelMessageHandler from rust threw an exception.");
13562         }
13563         LDKNodeFeatures ret_conv;
13564         ret_conv.inner = untag_ptr(ret);
13565         ret_conv.is_owned = ptr_is_owned(ret);
13566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13567         if (get_jenv_res == JNI_EDETACHED) {
13568                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13569         }
13570         return ret_conv;
13571 }
13572 LDKInitFeatures provided_init_features_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         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
13586         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13587                 (*env)->ExceptionDescribe(env);
13588                 (*env)->FatalError(env, "A call to provided_init_features in LDKChannelMessageHandler from rust threw an exception.");
13589         }
13590         LDKInitFeatures ret_conv;
13591         ret_conv.inner = untag_ptr(ret);
13592         ret_conv.is_owned = ptr_is_owned(ret);
13593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13594         if (get_jenv_res == JNI_EDETACHED) {
13595                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13596         }
13597         return ret_conv;
13598 }
13599 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
13600         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
13601         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13602         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
13603 }
13604 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13605         jclass c = (*env)->GetObjectClass(env, o);
13606         CHECK(c != NULL);
13607         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
13608         atomic_init(&calls->refcnt, 1);
13609         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13610         calls->o = (*env)->NewWeakGlobalRef(env, o);
13611         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJ)V");
13612         CHECK(calls->handle_open_channel_meth != NULL);
13613         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJ)V");
13614         CHECK(calls->handle_accept_channel_meth != NULL);
13615         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
13616         CHECK(calls->handle_funding_created_meth != NULL);
13617         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
13618         CHECK(calls->handle_funding_signed_meth != NULL);
13619         calls->handle_channel_ready_meth = (*env)->GetMethodID(env, c, "handle_channel_ready", "([BJ)V");
13620         CHECK(calls->handle_channel_ready_meth != NULL);
13621         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJ)V");
13622         CHECK(calls->handle_shutdown_meth != NULL);
13623         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
13624         CHECK(calls->handle_closing_signed_meth != NULL);
13625         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
13626         CHECK(calls->handle_update_add_htlc_meth != NULL);
13627         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
13628         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
13629         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
13630         CHECK(calls->handle_update_fail_htlc_meth != NULL);
13631         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
13632         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
13633         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
13634         CHECK(calls->handle_commitment_signed_meth != NULL);
13635         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
13636         CHECK(calls->handle_revoke_and_ack_meth != NULL);
13637         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
13638         CHECK(calls->handle_update_fee_meth != NULL);
13639         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
13640         CHECK(calls->handle_announcement_signatures_meth != NULL);
13641         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([B)V");
13642         CHECK(calls->peer_disconnected_meth != NULL);
13643         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJZ)J");
13644         CHECK(calls->peer_connected_meth != NULL);
13645         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
13646         CHECK(calls->handle_channel_reestablish_meth != NULL);
13647         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
13648         CHECK(calls->handle_channel_update_meth != NULL);
13649         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
13650         CHECK(calls->handle_error_meth != NULL);
13651         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
13652         CHECK(calls->provided_node_features_meth != NULL);
13653         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
13654         CHECK(calls->provided_init_features_meth != NULL);
13655
13656         LDKChannelMessageHandler ret = {
13657                 .this_arg = (void*) calls,
13658                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
13659                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
13660                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
13661                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
13662                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
13663                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
13664                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
13665                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
13666                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
13667                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
13668                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
13669                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
13670                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
13671                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
13672                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
13673                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
13674                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
13675                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
13676                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
13677                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
13678                 .provided_node_features = provided_node_features_LDKChannelMessageHandler_jcall,
13679                 .provided_init_features = provided_init_features_LDKChannelMessageHandler_jcall,
13680                 .free = LDKChannelMessageHandler_JCalls_free,
13681                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
13682         };
13683         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
13684         return ret;
13685 }
13686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13687         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
13688         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
13689         return tag_ptr(res_ptr, true);
13690 }
13691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
13692         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)untag_ptr(arg);
13693         return tag_ptr(&inp->MessageSendEventsProvider, false);
13694 }
13695 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) {
13696         void* this_arg_ptr = untag_ptr(this_arg);
13697         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13698         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13699         LDKPublicKey their_node_id_ref;
13700         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13701         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13702         LDKOpenChannel msg_conv;
13703         msg_conv.inner = untag_ptr(msg);
13704         msg_conv.is_owned = ptr_is_owned(msg);
13705         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13706         msg_conv.is_owned = false;
13707         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13708 }
13709
13710 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) {
13711         void* this_arg_ptr = untag_ptr(this_arg);
13712         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13713         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13714         LDKPublicKey their_node_id_ref;
13715         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13716         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13717         LDKAcceptChannel msg_conv;
13718         msg_conv.inner = untag_ptr(msg);
13719         msg_conv.is_owned = ptr_is_owned(msg);
13720         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13721         msg_conv.is_owned = false;
13722         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13723 }
13724
13725 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) {
13726         void* this_arg_ptr = untag_ptr(this_arg);
13727         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13728         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13729         LDKPublicKey their_node_id_ref;
13730         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13731         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13732         LDKFundingCreated msg_conv;
13733         msg_conv.inner = untag_ptr(msg);
13734         msg_conv.is_owned = ptr_is_owned(msg);
13735         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13736         msg_conv.is_owned = false;
13737         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13738 }
13739
13740 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) {
13741         void* this_arg_ptr = untag_ptr(this_arg);
13742         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13743         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13744         LDKPublicKey their_node_id_ref;
13745         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13746         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13747         LDKFundingSigned msg_conv;
13748         msg_conv.inner = untag_ptr(msg);
13749         msg_conv.is_owned = ptr_is_owned(msg);
13750         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13751         msg_conv.is_owned = false;
13752         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13753 }
13754
13755 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) {
13756         void* this_arg_ptr = untag_ptr(this_arg);
13757         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13758         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13759         LDKPublicKey their_node_id_ref;
13760         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13761         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13762         LDKChannelReady msg_conv;
13763         msg_conv.inner = untag_ptr(msg);
13764         msg_conv.is_owned = ptr_is_owned(msg);
13765         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13766         msg_conv.is_owned = false;
13767         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13768 }
13769
13770 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) {
13771         void* this_arg_ptr = untag_ptr(this_arg);
13772         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13773         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13774         LDKPublicKey their_node_id_ref;
13775         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13776         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13777         LDKShutdown msg_conv;
13778         msg_conv.inner = untag_ptr(msg);
13779         msg_conv.is_owned = ptr_is_owned(msg);
13780         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13781         msg_conv.is_owned = false;
13782         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13783 }
13784
13785 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) {
13786         void* this_arg_ptr = untag_ptr(this_arg);
13787         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13788         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13789         LDKPublicKey their_node_id_ref;
13790         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13791         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13792         LDKClosingSigned msg_conv;
13793         msg_conv.inner = untag_ptr(msg);
13794         msg_conv.is_owned = ptr_is_owned(msg);
13795         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13796         msg_conv.is_owned = false;
13797         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13798 }
13799
13800 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) {
13801         void* this_arg_ptr = untag_ptr(this_arg);
13802         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13803         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13804         LDKPublicKey their_node_id_ref;
13805         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13806         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13807         LDKUpdateAddHTLC msg_conv;
13808         msg_conv.inner = untag_ptr(msg);
13809         msg_conv.is_owned = ptr_is_owned(msg);
13810         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13811         msg_conv.is_owned = false;
13812         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13813 }
13814
13815 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) {
13816         void* this_arg_ptr = untag_ptr(this_arg);
13817         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13818         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13819         LDKPublicKey their_node_id_ref;
13820         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13821         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13822         LDKUpdateFulfillHTLC msg_conv;
13823         msg_conv.inner = untag_ptr(msg);
13824         msg_conv.is_owned = ptr_is_owned(msg);
13825         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13826         msg_conv.is_owned = false;
13827         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13828 }
13829
13830 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) {
13831         void* this_arg_ptr = untag_ptr(this_arg);
13832         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13833         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13834         LDKPublicKey their_node_id_ref;
13835         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13836         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13837         LDKUpdateFailHTLC msg_conv;
13838         msg_conv.inner = untag_ptr(msg);
13839         msg_conv.is_owned = ptr_is_owned(msg);
13840         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13841         msg_conv.is_owned = false;
13842         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13843 }
13844
13845 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) {
13846         void* this_arg_ptr = untag_ptr(this_arg);
13847         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13848         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13849         LDKPublicKey their_node_id_ref;
13850         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13851         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13852         LDKUpdateFailMalformedHTLC msg_conv;
13853         msg_conv.inner = untag_ptr(msg);
13854         msg_conv.is_owned = ptr_is_owned(msg);
13855         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13856         msg_conv.is_owned = false;
13857         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13858 }
13859
13860 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) {
13861         void* this_arg_ptr = untag_ptr(this_arg);
13862         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13863         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13864         LDKPublicKey their_node_id_ref;
13865         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13866         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13867         LDKCommitmentSigned msg_conv;
13868         msg_conv.inner = untag_ptr(msg);
13869         msg_conv.is_owned = ptr_is_owned(msg);
13870         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13871         msg_conv.is_owned = false;
13872         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13873 }
13874
13875 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) {
13876         void* this_arg_ptr = untag_ptr(this_arg);
13877         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13878         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13879         LDKPublicKey their_node_id_ref;
13880         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13881         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13882         LDKRevokeAndACK msg_conv;
13883         msg_conv.inner = untag_ptr(msg);
13884         msg_conv.is_owned = ptr_is_owned(msg);
13885         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13886         msg_conv.is_owned = false;
13887         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13888 }
13889
13890 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) {
13891         void* this_arg_ptr = untag_ptr(this_arg);
13892         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13893         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13894         LDKPublicKey their_node_id_ref;
13895         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13896         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13897         LDKUpdateFee msg_conv;
13898         msg_conv.inner = untag_ptr(msg);
13899         msg_conv.is_owned = ptr_is_owned(msg);
13900         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13901         msg_conv.is_owned = false;
13902         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13903 }
13904
13905 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) {
13906         void* this_arg_ptr = untag_ptr(this_arg);
13907         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13908         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13909         LDKPublicKey their_node_id_ref;
13910         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13911         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13912         LDKAnnouncementSignatures msg_conv;
13913         msg_conv.inner = untag_ptr(msg);
13914         msg_conv.is_owned = ptr_is_owned(msg);
13915         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13916         msg_conv.is_owned = false;
13917         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13918 }
13919
13920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id) {
13921         void* this_arg_ptr = untag_ptr(this_arg);
13922         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13923         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13924         LDKPublicKey their_node_id_ref;
13925         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13926         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13927         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref);
13928 }
13929
13930 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) {
13931         void* this_arg_ptr = untag_ptr(this_arg);
13932         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13933         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13934         LDKPublicKey their_node_id_ref;
13935         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13936         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13937         LDKInit msg_conv;
13938         msg_conv.inner = untag_ptr(msg);
13939         msg_conv.is_owned = ptr_is_owned(msg);
13940         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13941         msg_conv.is_owned = false;
13942         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13943         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv, inbound);
13944         return tag_ptr(ret_conv, true);
13945 }
13946
13947 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) {
13948         void* this_arg_ptr = untag_ptr(this_arg);
13949         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13950         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13951         LDKPublicKey their_node_id_ref;
13952         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13953         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13954         LDKChannelReestablish msg_conv;
13955         msg_conv.inner = untag_ptr(msg);
13956         msg_conv.is_owned = ptr_is_owned(msg);
13957         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13958         msg_conv.is_owned = false;
13959         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13960 }
13961
13962 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) {
13963         void* this_arg_ptr = untag_ptr(this_arg);
13964         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13965         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13966         LDKPublicKey their_node_id_ref;
13967         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13968         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13969         LDKChannelUpdate msg_conv;
13970         msg_conv.inner = untag_ptr(msg);
13971         msg_conv.is_owned = ptr_is_owned(msg);
13972         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13973         msg_conv.is_owned = false;
13974         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13975 }
13976
13977 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) {
13978         void* this_arg_ptr = untag_ptr(this_arg);
13979         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13980         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13981         LDKPublicKey their_node_id_ref;
13982         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13983         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13984         LDKErrorMessage msg_conv;
13985         msg_conv.inner = untag_ptr(msg);
13986         msg_conv.is_owned = ptr_is_owned(msg);
13987         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13988         msg_conv.is_owned = false;
13989         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13990 }
13991
13992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
13993         void* this_arg_ptr = untag_ptr(this_arg);
13994         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13995         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13996         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
13997         int64_t ret_ref = 0;
13998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13999         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14000         return ret_ref;
14001 }
14002
14003 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) {
14004         void* this_arg_ptr = untag_ptr(this_arg);
14005         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14006         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14007         LDKPublicKey their_node_id_ref;
14008         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14009         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14010         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
14011         int64_t ret_ref = 0;
14012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14013         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14014         return ret_ref;
14015 }
14016
14017 typedef struct LDKRoutingMessageHandler_JCalls {
14018         atomic_size_t refcnt;
14019         JavaVM *vm;
14020         jweak o;
14021         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
14022         jmethodID handle_node_announcement_meth;
14023         jmethodID handle_channel_announcement_meth;
14024         jmethodID handle_channel_update_meth;
14025         jmethodID get_next_channel_announcement_meth;
14026         jmethodID get_next_node_announcement_meth;
14027         jmethodID peer_connected_meth;
14028         jmethodID handle_reply_channel_range_meth;
14029         jmethodID handle_reply_short_channel_ids_end_meth;
14030         jmethodID handle_query_channel_range_meth;
14031         jmethodID handle_query_short_channel_ids_meth;
14032         jmethodID processing_queue_high_meth;
14033         jmethodID provided_node_features_meth;
14034         jmethodID provided_init_features_meth;
14035 } LDKRoutingMessageHandler_JCalls;
14036 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
14037         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14038         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14039                 JNIEnv *env;
14040                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14041                 if (get_jenv_res == JNI_EDETACHED) {
14042                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14043                 } else {
14044                         DO_ASSERT(get_jenv_res == JNI_OK);
14045                 }
14046                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14047                 if (get_jenv_res == JNI_EDETACHED) {
14048                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14049                 }
14050                 FREE(j_calls);
14051         }
14052 }
14053 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
14054         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14055         JNIEnv *env;
14056         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14057         if (get_jenv_res == JNI_EDETACHED) {
14058                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14059         } else {
14060                 DO_ASSERT(get_jenv_res == JNI_OK);
14061         }
14062         LDKNodeAnnouncement msg_var = *msg;
14063         int64_t msg_ref = 0;
14064         msg_var = NodeAnnouncement_clone(&msg_var);
14065         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14066         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14067         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14068         CHECK(obj != NULL);
14069         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
14070         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14071                 (*env)->ExceptionDescribe(env);
14072                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
14073         }
14074         void* ret_ptr = untag_ptr(ret);
14075         CHECK_ACCESS(ret_ptr);
14076         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
14077         FREE(untag_ptr(ret));
14078         if (get_jenv_res == JNI_EDETACHED) {
14079                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14080         }
14081         return ret_conv;
14082 }
14083 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
14084         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14085         JNIEnv *env;
14086         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14087         if (get_jenv_res == JNI_EDETACHED) {
14088                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14089         } else {
14090                 DO_ASSERT(get_jenv_res == JNI_OK);
14091         }
14092         LDKChannelAnnouncement msg_var = *msg;
14093         int64_t msg_ref = 0;
14094         msg_var = ChannelAnnouncement_clone(&msg_var);
14095         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14096         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14097         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14098         CHECK(obj != NULL);
14099         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
14100         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14101                 (*env)->ExceptionDescribe(env);
14102                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
14103         }
14104         void* ret_ptr = untag_ptr(ret);
14105         CHECK_ACCESS(ret_ptr);
14106         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
14107         FREE(untag_ptr(ret));
14108         if (get_jenv_res == JNI_EDETACHED) {
14109                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14110         }
14111         return ret_conv;
14112 }
14113 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
14114         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14115         JNIEnv *env;
14116         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14117         if (get_jenv_res == JNI_EDETACHED) {
14118                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14119         } else {
14120                 DO_ASSERT(get_jenv_res == JNI_OK);
14121         }
14122         LDKChannelUpdate msg_var = *msg;
14123         int64_t msg_ref = 0;
14124         msg_var = ChannelUpdate_clone(&msg_var);
14125         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14126         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14127         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14128         CHECK(obj != NULL);
14129         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
14130         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14131                 (*env)->ExceptionDescribe(env);
14132                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
14133         }
14134         void* ret_ptr = untag_ptr(ret);
14135         CHECK_ACCESS(ret_ptr);
14136         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
14137         FREE(untag_ptr(ret));
14138         if (get_jenv_res == JNI_EDETACHED) {
14139                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14140         }
14141         return ret_conv;
14142 }
14143 LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point) {
14144         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14145         JNIEnv *env;
14146         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14147         if (get_jenv_res == JNI_EDETACHED) {
14148                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14149         } else {
14150                 DO_ASSERT(get_jenv_res == JNI_OK);
14151         }
14152         int64_t starting_point_conv = starting_point;
14153         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14154         CHECK(obj != NULL);
14155         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_channel_announcement_meth, starting_point_conv);
14156         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14157                 (*env)->ExceptionDescribe(env);
14158                 (*env)->FatalError(env, "A call to get_next_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
14159         }
14160         void* ret_ptr = untag_ptr(ret);
14161         CHECK_ACCESS(ret_ptr);
14162         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(ret_ptr);
14163         FREE(untag_ptr(ret));
14164         if (get_jenv_res == JNI_EDETACHED) {
14165                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14166         }
14167         return ret_conv;
14168 }
14169 LDKNodeAnnouncement get_next_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKNodeId starting_point) {
14170         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14171         JNIEnv *env;
14172         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14173         if (get_jenv_res == JNI_EDETACHED) {
14174                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14175         } else {
14176                 DO_ASSERT(get_jenv_res == JNI_OK);
14177         }
14178         LDKNodeId starting_point_var = starting_point;
14179         int64_t starting_point_ref = 0;
14180         CHECK_INNER_FIELD_ACCESS_OR_NULL(starting_point_var);
14181         starting_point_ref = tag_ptr(starting_point_var.inner, starting_point_var.is_owned);
14182         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14183         CHECK(obj != NULL);
14184         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_node_announcement_meth, starting_point_ref);
14185         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14186                 (*env)->ExceptionDescribe(env);
14187                 (*env)->FatalError(env, "A call to get_next_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
14188         }
14189         LDKNodeAnnouncement ret_conv;
14190         ret_conv.inner = untag_ptr(ret);
14191         ret_conv.is_owned = ptr_is_owned(ret);
14192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14193         if (get_jenv_res == JNI_EDETACHED) {
14194                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14195         }
14196         return ret_conv;
14197 }
14198 LDKCResult_NoneNoneZ peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init, bool inbound) {
14199         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
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         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14208         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14209         LDKInit init_var = *init;
14210         int64_t init_ref = 0;
14211         init_var = Init_clone(&init_var);
14212         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
14213         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
14214         jboolean inbound_conv = inbound;
14215         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14216         CHECK(obj != NULL);
14217         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref, inbound_conv);
14218         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14219                 (*env)->ExceptionDescribe(env);
14220                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
14221         }
14222         void* ret_ptr = untag_ptr(ret);
14223         CHECK_ACCESS(ret_ptr);
14224         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
14225         FREE(untag_ptr(ret));
14226         if (get_jenv_res == JNI_EDETACHED) {
14227                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14228         }
14229         return ret_conv;
14230 }
14231 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
14232         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14233         JNIEnv *env;
14234         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14235         if (get_jenv_res == JNI_EDETACHED) {
14236                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14237         } else {
14238                 DO_ASSERT(get_jenv_res == JNI_OK);
14239         }
14240         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14241         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14242         LDKReplyChannelRange msg_var = msg;
14243         int64_t msg_ref = 0;
14244         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14245         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14246         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14247         CHECK(obj != NULL);
14248         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
14249         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14250                 (*env)->ExceptionDescribe(env);
14251                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
14252         }
14253         void* ret_ptr = untag_ptr(ret);
14254         CHECK_ACCESS(ret_ptr);
14255         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14256         FREE(untag_ptr(ret));
14257         if (get_jenv_res == JNI_EDETACHED) {
14258                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14259         }
14260         return ret_conv;
14261 }
14262 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
14263         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14264         JNIEnv *env;
14265         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14266         if (get_jenv_res == JNI_EDETACHED) {
14267                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14268         } else {
14269                 DO_ASSERT(get_jenv_res == JNI_OK);
14270         }
14271         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14272         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14273         LDKReplyShortChannelIdsEnd msg_var = msg;
14274         int64_t msg_ref = 0;
14275         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14276         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14277         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14278         CHECK(obj != NULL);
14279         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
14280         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14281                 (*env)->ExceptionDescribe(env);
14282                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
14283         }
14284         void* ret_ptr = untag_ptr(ret);
14285         CHECK_ACCESS(ret_ptr);
14286         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14287         FREE(untag_ptr(ret));
14288         if (get_jenv_res == JNI_EDETACHED) {
14289                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14290         }
14291         return ret_conv;
14292 }
14293 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
14294         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14295         JNIEnv *env;
14296         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14297         if (get_jenv_res == JNI_EDETACHED) {
14298                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14299         } else {
14300                 DO_ASSERT(get_jenv_res == JNI_OK);
14301         }
14302         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14303         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14304         LDKQueryChannelRange msg_var = msg;
14305         int64_t msg_ref = 0;
14306         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14307         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14308         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14309         CHECK(obj != NULL);
14310         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
14311         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14312                 (*env)->ExceptionDescribe(env);
14313                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
14314         }
14315         void* ret_ptr = untag_ptr(ret);
14316         CHECK_ACCESS(ret_ptr);
14317         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14318         FREE(untag_ptr(ret));
14319         if (get_jenv_res == JNI_EDETACHED) {
14320                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14321         }
14322         return ret_conv;
14323 }
14324 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
14325         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14326         JNIEnv *env;
14327         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14328         if (get_jenv_res == JNI_EDETACHED) {
14329                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14330         } else {
14331                 DO_ASSERT(get_jenv_res == JNI_OK);
14332         }
14333         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14334         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14335         LDKQueryShortChannelIds msg_var = msg;
14336         int64_t msg_ref = 0;
14337         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14338         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14339         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14340         CHECK(obj != NULL);
14341         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
14342         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14343                 (*env)->ExceptionDescribe(env);
14344                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
14345         }
14346         void* ret_ptr = untag_ptr(ret);
14347         CHECK_ACCESS(ret_ptr);
14348         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14349         FREE(untag_ptr(ret));
14350         if (get_jenv_res == JNI_EDETACHED) {
14351                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14352         }
14353         return ret_conv;
14354 }
14355 bool processing_queue_high_LDKRoutingMessageHandler_jcall(const void* this_arg) {
14356         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14357         JNIEnv *env;
14358         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14359         if (get_jenv_res == JNI_EDETACHED) {
14360                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14361         } else {
14362                 DO_ASSERT(get_jenv_res == JNI_OK);
14363         }
14364         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14365         CHECK(obj != NULL);
14366         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->processing_queue_high_meth);
14367         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14368                 (*env)->ExceptionDescribe(env);
14369                 (*env)->FatalError(env, "A call to processing_queue_high in LDKRoutingMessageHandler from rust threw an exception.");
14370         }
14371         if (get_jenv_res == JNI_EDETACHED) {
14372                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14373         }
14374         return ret;
14375 }
14376 LDKNodeFeatures provided_node_features_LDKRoutingMessageHandler_jcall(const void* this_arg) {
14377         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14378         JNIEnv *env;
14379         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14380         if (get_jenv_res == JNI_EDETACHED) {
14381                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14382         } else {
14383                 DO_ASSERT(get_jenv_res == JNI_OK);
14384         }
14385         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14386         CHECK(obj != NULL);
14387         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
14388         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14389                 (*env)->ExceptionDescribe(env);
14390                 (*env)->FatalError(env, "A call to provided_node_features in LDKRoutingMessageHandler from rust threw an exception.");
14391         }
14392         LDKNodeFeatures ret_conv;
14393         ret_conv.inner = untag_ptr(ret);
14394         ret_conv.is_owned = ptr_is_owned(ret);
14395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14396         if (get_jenv_res == JNI_EDETACHED) {
14397                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14398         }
14399         return ret_conv;
14400 }
14401 LDKInitFeatures provided_init_features_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
14402         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14403         JNIEnv *env;
14404         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14405         if (get_jenv_res == JNI_EDETACHED) {
14406                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14407         } else {
14408                 DO_ASSERT(get_jenv_res == JNI_OK);
14409         }
14410         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14411         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14412         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14413         CHECK(obj != NULL);
14414         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
14415         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14416                 (*env)->ExceptionDescribe(env);
14417                 (*env)->FatalError(env, "A call to provided_init_features in LDKRoutingMessageHandler from rust threw an exception.");
14418         }
14419         LDKInitFeatures ret_conv;
14420         ret_conv.inner = untag_ptr(ret);
14421         ret_conv.is_owned = ptr_is_owned(ret);
14422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14423         if (get_jenv_res == JNI_EDETACHED) {
14424                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14425         }
14426         return ret_conv;
14427 }
14428 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
14429         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
14430         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14431         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
14432 }
14433 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
14434         jclass c = (*env)->GetObjectClass(env, o);
14435         CHECK(c != NULL);
14436         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
14437         atomic_init(&calls->refcnt, 1);
14438         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14439         calls->o = (*env)->NewWeakGlobalRef(env, o);
14440         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
14441         CHECK(calls->handle_node_announcement_meth != NULL);
14442         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
14443         CHECK(calls->handle_channel_announcement_meth != NULL);
14444         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
14445         CHECK(calls->handle_channel_update_meth != NULL);
14446         calls->get_next_channel_announcement_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcement", "(J)J");
14447         CHECK(calls->get_next_channel_announcement_meth != NULL);
14448         calls->get_next_node_announcement_meth = (*env)->GetMethodID(env, c, "get_next_node_announcement", "(J)J");
14449         CHECK(calls->get_next_node_announcement_meth != NULL);
14450         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJZ)J");
14451         CHECK(calls->peer_connected_meth != NULL);
14452         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
14453         CHECK(calls->handle_reply_channel_range_meth != NULL);
14454         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
14455         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
14456         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
14457         CHECK(calls->handle_query_channel_range_meth != NULL);
14458         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
14459         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
14460         calls->processing_queue_high_meth = (*env)->GetMethodID(env, c, "processing_queue_high", "()Z");
14461         CHECK(calls->processing_queue_high_meth != NULL);
14462         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
14463         CHECK(calls->provided_node_features_meth != NULL);
14464         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
14465         CHECK(calls->provided_init_features_meth != NULL);
14466
14467         LDKRoutingMessageHandler ret = {
14468                 .this_arg = (void*) calls,
14469                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
14470                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
14471                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
14472                 .get_next_channel_announcement = get_next_channel_announcement_LDKRoutingMessageHandler_jcall,
14473                 .get_next_node_announcement = get_next_node_announcement_LDKRoutingMessageHandler_jcall,
14474                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
14475                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
14476                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
14477                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
14478                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
14479                 .processing_queue_high = processing_queue_high_LDKRoutingMessageHandler_jcall,
14480                 .provided_node_features = provided_node_features_LDKRoutingMessageHandler_jcall,
14481                 .provided_init_features = provided_init_features_LDKRoutingMessageHandler_jcall,
14482                 .free = LDKRoutingMessageHandler_JCalls_free,
14483                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
14484         };
14485         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
14486         return ret;
14487 }
14488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
14489         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
14490         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
14491         return tag_ptr(res_ptr, true);
14492 }
14493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
14494         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)untag_ptr(arg);
14495         return tag_ptr(&inp->MessageSendEventsProvider, false);
14496 }
14497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
14498         void* this_arg_ptr = untag_ptr(this_arg);
14499         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14500         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14501         LDKNodeAnnouncement msg_conv;
14502         msg_conv.inner = untag_ptr(msg);
14503         msg_conv.is_owned = ptr_is_owned(msg);
14504         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14505         msg_conv.is_owned = false;
14506         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14507         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
14508         return tag_ptr(ret_conv, true);
14509 }
14510
14511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
14512         void* this_arg_ptr = untag_ptr(this_arg);
14513         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14514         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14515         LDKChannelAnnouncement msg_conv;
14516         msg_conv.inner = untag_ptr(msg);
14517         msg_conv.is_owned = ptr_is_owned(msg);
14518         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14519         msg_conv.is_owned = false;
14520         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14521         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
14522         return tag_ptr(ret_conv, true);
14523 }
14524
14525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
14526         void* this_arg_ptr = untag_ptr(this_arg);
14527         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14528         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14529         LDKChannelUpdate msg_conv;
14530         msg_conv.inner = untag_ptr(msg);
14531         msg_conv.is_owned = ptr_is_owned(msg);
14532         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14533         msg_conv.is_owned = false;
14534         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14535         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
14536         return tag_ptr(ret_conv, true);
14537 }
14538
14539 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) {
14540         void* this_arg_ptr = untag_ptr(this_arg);
14541         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14542         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14543         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
14544         *ret_copy = (this_arg_conv->get_next_channel_announcement)(this_arg_conv->this_arg, starting_point);
14545         int64_t ret_ref = tag_ptr(ret_copy, true);
14546         return ret_ref;
14547 }
14548
14549 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) {
14550         void* this_arg_ptr = untag_ptr(this_arg);
14551         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14552         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14553         LDKNodeId starting_point_conv;
14554         starting_point_conv.inner = untag_ptr(starting_point);
14555         starting_point_conv.is_owned = ptr_is_owned(starting_point);
14556         CHECK_INNER_FIELD_ACCESS_OR_NULL(starting_point_conv);
14557         starting_point_conv = NodeId_clone(&starting_point_conv);
14558         LDKNodeAnnouncement ret_var = (this_arg_conv->get_next_node_announcement)(this_arg_conv->this_arg, starting_point_conv);
14559         int64_t ret_ref = 0;
14560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14561         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14562         return ret_ref;
14563 }
14564
14565 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) {
14566         void* this_arg_ptr = untag_ptr(this_arg);
14567         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14568         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14569         LDKPublicKey their_node_id_ref;
14570         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14571         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14572         LDKInit init_conv;
14573         init_conv.inner = untag_ptr(init);
14574         init_conv.is_owned = ptr_is_owned(init);
14575         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
14576         init_conv.is_owned = false;
14577         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14578         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv, inbound);
14579         return tag_ptr(ret_conv, true);
14580 }
14581
14582 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) {
14583         void* this_arg_ptr = untag_ptr(this_arg);
14584         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14585         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14586         LDKPublicKey their_node_id_ref;
14587         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14588         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14589         LDKReplyChannelRange msg_conv;
14590         msg_conv.inner = untag_ptr(msg);
14591         msg_conv.is_owned = ptr_is_owned(msg);
14592         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14593         msg_conv = ReplyChannelRange_clone(&msg_conv);
14594         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14595         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14596         return tag_ptr(ret_conv, true);
14597 }
14598
14599 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) {
14600         void* this_arg_ptr = untag_ptr(this_arg);
14601         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14602         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14603         LDKPublicKey their_node_id_ref;
14604         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14605         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14606         LDKReplyShortChannelIdsEnd msg_conv;
14607         msg_conv.inner = untag_ptr(msg);
14608         msg_conv.is_owned = ptr_is_owned(msg);
14609         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14610         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
14611         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14612         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14613         return tag_ptr(ret_conv, true);
14614 }
14615
14616 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) {
14617         void* this_arg_ptr = untag_ptr(this_arg);
14618         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14619         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14620         LDKPublicKey their_node_id_ref;
14621         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14622         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14623         LDKQueryChannelRange msg_conv;
14624         msg_conv.inner = untag_ptr(msg);
14625         msg_conv.is_owned = ptr_is_owned(msg);
14626         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14627         msg_conv = QueryChannelRange_clone(&msg_conv);
14628         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14629         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14630         return tag_ptr(ret_conv, true);
14631 }
14632
14633 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) {
14634         void* this_arg_ptr = untag_ptr(this_arg);
14635         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14636         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14637         LDKPublicKey their_node_id_ref;
14638         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14639         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14640         LDKQueryShortChannelIds msg_conv;
14641         msg_conv.inner = untag_ptr(msg);
14642         msg_conv.is_owned = ptr_is_owned(msg);
14643         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14644         msg_conv = QueryShortChannelIds_clone(&msg_conv);
14645         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14646         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14647         return tag_ptr(ret_conv, true);
14648 }
14649
14650 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1processing_1queue_1high(JNIEnv *env, jclass clz, int64_t this_arg) {
14651         void* this_arg_ptr = untag_ptr(this_arg);
14652         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14653         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14654         jboolean ret_conv = (this_arg_conv->processing_queue_high)(this_arg_conv->this_arg);
14655         return ret_conv;
14656 }
14657
14658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
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         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
14663         int64_t ret_ref = 0;
14664         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14665         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14666         return ret_ref;
14667 }
14668
14669 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) {
14670         void* this_arg_ptr = untag_ptr(this_arg);
14671         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14672         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14673         LDKPublicKey their_node_id_ref;
14674         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14675         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14676         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
14677         int64_t ret_ref = 0;
14678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14679         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14680         return ret_ref;
14681 }
14682
14683 typedef struct LDKOnionMessageHandler_JCalls {
14684         atomic_size_t refcnt;
14685         JavaVM *vm;
14686         jweak o;
14687         LDKOnionMessageProvider_JCalls* OnionMessageProvider;
14688         jmethodID handle_onion_message_meth;
14689         jmethodID peer_connected_meth;
14690         jmethodID peer_disconnected_meth;
14691         jmethodID provided_node_features_meth;
14692         jmethodID provided_init_features_meth;
14693 } LDKOnionMessageHandler_JCalls;
14694 static void LDKOnionMessageHandler_JCalls_free(void* this_arg) {
14695         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14696         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14697                 JNIEnv *env;
14698                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14699                 if (get_jenv_res == JNI_EDETACHED) {
14700                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14701                 } else {
14702                         DO_ASSERT(get_jenv_res == JNI_OK);
14703                 }
14704                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14705                 if (get_jenv_res == JNI_EDETACHED) {
14706                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14707                 }
14708                 FREE(j_calls);
14709         }
14710 }
14711 void handle_onion_message_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey peer_node_id, const LDKOnionMessage * msg) {
14712         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14713         JNIEnv *env;
14714         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14715         if (get_jenv_res == JNI_EDETACHED) {
14716                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14717         } else {
14718                 DO_ASSERT(get_jenv_res == JNI_OK);
14719         }
14720         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
14721         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
14722         LDKOnionMessage msg_var = *msg;
14723         int64_t msg_ref = 0;
14724         msg_var = OnionMessage_clone(&msg_var);
14725         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14726         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14727         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14728         CHECK(obj != NULL);
14729         (*env)->CallVoidMethod(env, obj, j_calls->handle_onion_message_meth, peer_node_id_arr, msg_ref);
14730         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14731                 (*env)->ExceptionDescribe(env);
14732                 (*env)->FatalError(env, "A call to handle_onion_message in LDKOnionMessageHandler from rust threw an exception.");
14733         }
14734         if (get_jenv_res == JNI_EDETACHED) {
14735                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14736         }
14737 }
14738 LDKCResult_NoneNoneZ peer_connected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init, bool inbound) {
14739         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14740         JNIEnv *env;
14741         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14742         if (get_jenv_res == JNI_EDETACHED) {
14743                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14744         } else {
14745                 DO_ASSERT(get_jenv_res == JNI_OK);
14746         }
14747         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14748         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14749         LDKInit init_var = *init;
14750         int64_t init_ref = 0;
14751         init_var = Init_clone(&init_var);
14752         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
14753         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
14754         jboolean inbound_conv = inbound;
14755         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14756         CHECK(obj != NULL);
14757         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref, inbound_conv);
14758         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14759                 (*env)->ExceptionDescribe(env);
14760                 (*env)->FatalError(env, "A call to peer_connected in LDKOnionMessageHandler from rust threw an exception.");
14761         }
14762         void* ret_ptr = untag_ptr(ret);
14763         CHECK_ACCESS(ret_ptr);
14764         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
14765         FREE(untag_ptr(ret));
14766         if (get_jenv_res == JNI_EDETACHED) {
14767                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14768         }
14769         return ret_conv;
14770 }
14771 void peer_disconnected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
14772         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14773         JNIEnv *env;
14774         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14775         if (get_jenv_res == JNI_EDETACHED) {
14776                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14777         } else {
14778                 DO_ASSERT(get_jenv_res == JNI_OK);
14779         }
14780         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14781         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14782         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14783         CHECK(obj != NULL);
14784         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr);
14785         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14786                 (*env)->ExceptionDescribe(env);
14787                 (*env)->FatalError(env, "A call to peer_disconnected in LDKOnionMessageHandler from rust threw an exception.");
14788         }
14789         if (get_jenv_res == JNI_EDETACHED) {
14790                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14791         }
14792 }
14793 LDKNodeFeatures provided_node_features_LDKOnionMessageHandler_jcall(const void* this_arg) {
14794         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14795         JNIEnv *env;
14796         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14797         if (get_jenv_res == JNI_EDETACHED) {
14798                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14799         } else {
14800                 DO_ASSERT(get_jenv_res == JNI_OK);
14801         }
14802         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14803         CHECK(obj != NULL);
14804         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
14805         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14806                 (*env)->ExceptionDescribe(env);
14807                 (*env)->FatalError(env, "A call to provided_node_features in LDKOnionMessageHandler from rust threw an exception.");
14808         }
14809         LDKNodeFeatures ret_conv;
14810         ret_conv.inner = untag_ptr(ret);
14811         ret_conv.is_owned = ptr_is_owned(ret);
14812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14813         if (get_jenv_res == JNI_EDETACHED) {
14814                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14815         }
14816         return ret_conv;
14817 }
14818 LDKInitFeatures provided_init_features_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
14819         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14820         JNIEnv *env;
14821         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14822         if (get_jenv_res == JNI_EDETACHED) {
14823                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14824         } else {
14825                 DO_ASSERT(get_jenv_res == JNI_OK);
14826         }
14827         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14828         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14829         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14830         CHECK(obj != NULL);
14831         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
14832         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14833                 (*env)->ExceptionDescribe(env);
14834                 (*env)->FatalError(env, "A call to provided_init_features in LDKOnionMessageHandler from rust threw an exception.");
14835         }
14836         LDKInitFeatures ret_conv;
14837         ret_conv.inner = untag_ptr(ret);
14838         ret_conv.is_owned = ptr_is_owned(ret);
14839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14840         if (get_jenv_res == JNI_EDETACHED) {
14841                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14842         }
14843         return ret_conv;
14844 }
14845 static void LDKOnionMessageHandler_JCalls_cloned(LDKOnionMessageHandler* new_obj) {
14846         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) new_obj->this_arg;
14847         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14848         atomic_fetch_add_explicit(&j_calls->OnionMessageProvider->refcnt, 1, memory_order_release);
14849 }
14850 static inline LDKOnionMessageHandler LDKOnionMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
14851         jclass c = (*env)->GetObjectClass(env, o);
14852         CHECK(c != NULL);
14853         LDKOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKOnionMessageHandler_JCalls), "LDKOnionMessageHandler_JCalls");
14854         atomic_init(&calls->refcnt, 1);
14855         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14856         calls->o = (*env)->NewWeakGlobalRef(env, o);
14857         calls->handle_onion_message_meth = (*env)->GetMethodID(env, c, "handle_onion_message", "([BJ)V");
14858         CHECK(calls->handle_onion_message_meth != NULL);
14859         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJZ)J");
14860         CHECK(calls->peer_connected_meth != NULL);
14861         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([B)V");
14862         CHECK(calls->peer_disconnected_meth != NULL);
14863         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
14864         CHECK(calls->provided_node_features_meth != NULL);
14865         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
14866         CHECK(calls->provided_init_features_meth != NULL);
14867
14868         LDKOnionMessageHandler ret = {
14869                 .this_arg = (void*) calls,
14870                 .handle_onion_message = handle_onion_message_LDKOnionMessageHandler_jcall,
14871                 .peer_connected = peer_connected_LDKOnionMessageHandler_jcall,
14872                 .peer_disconnected = peer_disconnected_LDKOnionMessageHandler_jcall,
14873                 .provided_node_features = provided_node_features_LDKOnionMessageHandler_jcall,
14874                 .provided_init_features = provided_init_features_LDKOnionMessageHandler_jcall,
14875                 .free = LDKOnionMessageHandler_JCalls_free,
14876                 .OnionMessageProvider = LDKOnionMessageProvider_init(env, clz, OnionMessageProvider),
14877         };
14878         calls->OnionMessageProvider = ret.OnionMessageProvider.this_arg;
14879         return ret;
14880 }
14881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
14882         LDKOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
14883         *res_ptr = LDKOnionMessageHandler_init(env, clz, o, OnionMessageProvider);
14884         return tag_ptr(res_ptr, true);
14885 }
14886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1get_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t arg) {
14887         LDKOnionMessageHandler *inp = (LDKOnionMessageHandler *)untag_ptr(arg);
14888         return tag_ptr(&inp->OnionMessageProvider, false);
14889 }
14890 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) {
14891         void* this_arg_ptr = untag_ptr(this_arg);
14892         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14893         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14894         LDKPublicKey peer_node_id_ref;
14895         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
14896         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
14897         LDKOnionMessage msg_conv;
14898         msg_conv.inner = untag_ptr(msg);
14899         msg_conv.is_owned = ptr_is_owned(msg);
14900         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14901         msg_conv.is_owned = false;
14902         (this_arg_conv->handle_onion_message)(this_arg_conv->this_arg, peer_node_id_ref, &msg_conv);
14903 }
14904
14905 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) {
14906         void* this_arg_ptr = untag_ptr(this_arg);
14907         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14908         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14909         LDKPublicKey their_node_id_ref;
14910         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14911         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14912         LDKInit init_conv;
14913         init_conv.inner = untag_ptr(init);
14914         init_conv.is_owned = ptr_is_owned(init);
14915         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
14916         init_conv.is_owned = false;
14917         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14918         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv, inbound);
14919         return tag_ptr(ret_conv, true);
14920 }
14921
14922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1peer_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id) {
14923         void* this_arg_ptr = untag_ptr(this_arg);
14924         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14925         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14926         LDKPublicKey their_node_id_ref;
14927         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14928         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14929         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref);
14930 }
14931
14932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
14933         void* this_arg_ptr = untag_ptr(this_arg);
14934         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14935         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14936         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
14937         int64_t ret_ref = 0;
14938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14939         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14940         return ret_ref;
14941 }
14942
14943 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) {
14944         void* this_arg_ptr = untag_ptr(this_arg);
14945         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14946         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14947         LDKPublicKey their_node_id_ref;
14948         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14949         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14950         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
14951         int64_t ret_ref = 0;
14952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14953         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14954         return ret_ref;
14955 }
14956
14957 typedef struct LDKCustomMessageReader_JCalls {
14958         atomic_size_t refcnt;
14959         JavaVM *vm;
14960         jweak o;
14961         jmethodID read_meth;
14962 } LDKCustomMessageReader_JCalls;
14963 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
14964         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
14965         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14966                 JNIEnv *env;
14967                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14968                 if (get_jenv_res == JNI_EDETACHED) {
14969                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14970                 } else {
14971                         DO_ASSERT(get_jenv_res == JNI_OK);
14972                 }
14973                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14974                 if (get_jenv_res == JNI_EDETACHED) {
14975                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14976                 }
14977                 FREE(j_calls);
14978         }
14979 }
14980 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
14981         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
14982         JNIEnv *env;
14983         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14984         if (get_jenv_res == JNI_EDETACHED) {
14985                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14986         } else {
14987                 DO_ASSERT(get_jenv_res == JNI_OK);
14988         }
14989         int16_t message_type_conv = message_type;
14990         LDKu8slice buffer_var = buffer;
14991         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
14992         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
14993         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14994         CHECK(obj != NULL);
14995         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
14996         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14997                 (*env)->ExceptionDescribe(env);
14998                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
14999         }
15000         void* ret_ptr = untag_ptr(ret);
15001         CHECK_ACCESS(ret_ptr);
15002         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
15003         FREE(untag_ptr(ret));
15004         if (get_jenv_res == JNI_EDETACHED) {
15005                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15006         }
15007         return ret_conv;
15008 }
15009 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
15010         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
15011         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15012 }
15013 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
15014         jclass c = (*env)->GetObjectClass(env, o);
15015         CHECK(c != NULL);
15016         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
15017         atomic_init(&calls->refcnt, 1);
15018         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15019         calls->o = (*env)->NewWeakGlobalRef(env, o);
15020         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
15021         CHECK(calls->read_meth != NULL);
15022
15023         LDKCustomMessageReader ret = {
15024                 .this_arg = (void*) calls,
15025                 .read = read_LDKCustomMessageReader_jcall,
15026                 .free = LDKCustomMessageReader_JCalls_free,
15027         };
15028         return ret;
15029 }
15030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
15031         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
15032         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
15033         return tag_ptr(res_ptr, true);
15034 }
15035 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) {
15036         void* this_arg_ptr = untag_ptr(this_arg);
15037         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15038         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
15039         LDKu8slice buffer_ref;
15040         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
15041         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
15042         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15043         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
15044         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
15045         return tag_ptr(ret_conv, true);
15046 }
15047
15048 typedef struct LDKCustomMessageHandler_JCalls {
15049         atomic_size_t refcnt;
15050         JavaVM *vm;
15051         jweak o;
15052         LDKCustomMessageReader_JCalls* CustomMessageReader;
15053         jmethodID handle_custom_message_meth;
15054         jmethodID get_and_clear_pending_msg_meth;
15055 } LDKCustomMessageHandler_JCalls;
15056 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
15057         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
15058         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15059                 JNIEnv *env;
15060                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15061                 if (get_jenv_res == JNI_EDETACHED) {
15062                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15063                 } else {
15064                         DO_ASSERT(get_jenv_res == JNI_OK);
15065                 }
15066                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
15067                 if (get_jenv_res == JNI_EDETACHED) {
15068                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15069                 }
15070                 FREE(j_calls);
15071         }
15072 }
15073 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
15074         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
15075         JNIEnv *env;
15076         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15077         if (get_jenv_res == JNI_EDETACHED) {
15078                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15079         } else {
15080                 DO_ASSERT(get_jenv_res == JNI_OK);
15081         }
15082         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
15083         *msg_ret = msg;
15084         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
15085         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
15086         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15087         CHECK(obj != NULL);
15088         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true), sender_node_id_arr);
15089         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15090                 (*env)->ExceptionDescribe(env);
15091                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
15092         }
15093         void* ret_ptr = untag_ptr(ret);
15094         CHECK_ACCESS(ret_ptr);
15095         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
15096         FREE(untag_ptr(ret));
15097         if (get_jenv_res == JNI_EDETACHED) {
15098                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15099         }
15100         return ret_conv;
15101 }
15102 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
15103         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
15104         JNIEnv *env;
15105         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15106         if (get_jenv_res == JNI_EDETACHED) {
15107                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15108         } else {
15109                 DO_ASSERT(get_jenv_res == JNI_OK);
15110         }
15111         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15112         CHECK(obj != NULL);
15113         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
15114         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15115                 (*env)->ExceptionDescribe(env);
15116                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
15117         }
15118         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
15119         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
15120         if (ret_constr.datalen > 0)
15121                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
15122         else
15123                 ret_constr.data = NULL;
15124         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
15125         for (size_t z = 0; z < ret_constr.datalen; z++) {
15126                 int64_t ret_conv_25 = ret_vals[z];
15127                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
15128                 CHECK_ACCESS(ret_conv_25_ptr);
15129                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
15130                 FREE(untag_ptr(ret_conv_25));
15131                 ret_constr.data[z] = ret_conv_25_conv;
15132         }
15133         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
15134         if (get_jenv_res == JNI_EDETACHED) {
15135                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15136         }
15137         return ret_constr;
15138 }
15139 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
15140         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
15141         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15142         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
15143 }
15144 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
15145         jclass c = (*env)->GetObjectClass(env, o);
15146         CHECK(c != NULL);
15147         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
15148         atomic_init(&calls->refcnt, 1);
15149         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15150         calls->o = (*env)->NewWeakGlobalRef(env, o);
15151         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
15152         CHECK(calls->handle_custom_message_meth != NULL);
15153         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
15154         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
15155
15156         LDKCustomMessageHandler ret = {
15157                 .this_arg = (void*) calls,
15158                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
15159                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
15160                 .free = LDKCustomMessageHandler_JCalls_free,
15161                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
15162         };
15163         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
15164         return ret;
15165 }
15166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
15167         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
15168         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
15169         return tag_ptr(res_ptr, true);
15170 }
15171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
15172         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)untag_ptr(arg);
15173         return tag_ptr(&inp->CustomMessageReader, false);
15174 }
15175 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) {
15176         void* this_arg_ptr = untag_ptr(this_arg);
15177         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15178         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
15179         void* msg_ptr = untag_ptr(msg);
15180         CHECK_ACCESS(msg_ptr);
15181         LDKType msg_conv = *(LDKType*)(msg_ptr);
15182         if (msg_conv.free == LDKType_JCalls_free) {
15183                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15184                 LDKType_JCalls_cloned(&msg_conv);
15185         }
15186         LDKPublicKey sender_node_id_ref;
15187         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
15188         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
15189         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15190         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
15191         return tag_ptr(ret_conv, true);
15192 }
15193
15194 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
15195         void* this_arg_ptr = untag_ptr(this_arg);
15196         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15197         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
15198         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
15199         int64_tArray ret_arr = NULL;
15200         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15201         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15202         for (size_t z = 0; z < ret_var.datalen; z++) {
15203                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
15204                 *ret_conv_25_conv = ret_var.data[z];
15205                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
15206         }
15207         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15208         FREE(ret_var.data);
15209         return ret_arr;
15210 }
15211
15212 typedef struct LDKCustomOnionMessageHandler_JCalls {
15213         atomic_size_t refcnt;
15214         JavaVM *vm;
15215         jweak o;
15216         jmethodID handle_custom_message_meth;
15217         jmethodID read_custom_message_meth;
15218 } LDKCustomOnionMessageHandler_JCalls;
15219 static void LDKCustomOnionMessageHandler_JCalls_free(void* this_arg) {
15220         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
15221         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15222                 JNIEnv *env;
15223                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15224                 if (get_jenv_res == JNI_EDETACHED) {
15225                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15226                 } else {
15227                         DO_ASSERT(get_jenv_res == JNI_OK);
15228                 }
15229                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
15230                 if (get_jenv_res == JNI_EDETACHED) {
15231                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15232                 }
15233                 FREE(j_calls);
15234         }
15235 }
15236 void handle_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, LDKCustomOnionMessageContents msg) {
15237         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
15238         JNIEnv *env;
15239         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15240         if (get_jenv_res == JNI_EDETACHED) {
15241                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15242         } else {
15243                 DO_ASSERT(get_jenv_res == JNI_OK);
15244         }
15245         LDKCustomOnionMessageContents* msg_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
15246         *msg_ret = msg;
15247         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15248         CHECK(obj != NULL);
15249         (*env)->CallVoidMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true));
15250         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15251                 (*env)->ExceptionDescribe(env);
15252                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomOnionMessageHandler from rust threw an exception.");
15253         }
15254         if (get_jenv_res == JNI_EDETACHED) {
15255                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15256         }
15257 }
15258 LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ read_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, uint64_t message_type, LDKu8slice buffer) {
15259         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
15260         JNIEnv *env;
15261         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15262         if (get_jenv_res == JNI_EDETACHED) {
15263                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15264         } else {
15265                 DO_ASSERT(get_jenv_res == JNI_OK);
15266         }
15267         int64_t message_type_conv = message_type;
15268         LDKu8slice buffer_var = buffer;
15269         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
15270         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
15271         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15272         CHECK(obj != NULL);
15273         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_custom_message_meth, message_type_conv, buffer_arr);
15274         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15275                 (*env)->ExceptionDescribe(env);
15276                 (*env)->FatalError(env, "A call to read_custom_message in LDKCustomOnionMessageHandler from rust threw an exception.");
15277         }
15278         void* ret_ptr = untag_ptr(ret);
15279         CHECK_ACCESS(ret_ptr);
15280         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ ret_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(ret_ptr);
15281         FREE(untag_ptr(ret));
15282         if (get_jenv_res == JNI_EDETACHED) {
15283                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15284         }
15285         return ret_conv;
15286 }
15287 static void LDKCustomOnionMessageHandler_JCalls_cloned(LDKCustomOnionMessageHandler* new_obj) {
15288         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) new_obj->this_arg;
15289         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15290 }
15291 static inline LDKCustomOnionMessageHandler LDKCustomOnionMessageHandler_init (JNIEnv *env, jclass clz, jobject o) {
15292         jclass c = (*env)->GetObjectClass(env, o);
15293         CHECK(c != NULL);
15294         LDKCustomOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageHandler_JCalls), "LDKCustomOnionMessageHandler_JCalls");
15295         atomic_init(&calls->refcnt, 1);
15296         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15297         calls->o = (*env)->NewWeakGlobalRef(env, o);
15298         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J)V");
15299         CHECK(calls->handle_custom_message_meth != NULL);
15300         calls->read_custom_message_meth = (*env)->GetMethodID(env, c, "read_custom_message", "(J[B)J");
15301         CHECK(calls->read_custom_message_meth != NULL);
15302
15303         LDKCustomOnionMessageHandler ret = {
15304                 .this_arg = (void*) calls,
15305                 .handle_custom_message = handle_custom_message_LDKCustomOnionMessageHandler_jcall,
15306                 .read_custom_message = read_custom_message_LDKCustomOnionMessageHandler_jcall,
15307                 .free = LDKCustomOnionMessageHandler_JCalls_free,
15308         };
15309         return ret;
15310 }
15311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomOnionMessageHandler_1new(JNIEnv *env, jclass clz, jobject o) {
15312         LDKCustomOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
15313         *res_ptr = LDKCustomOnionMessageHandler_init(env, clz, o);
15314         return tag_ptr(res_ptr, true);
15315 }
15316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1handle_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
15317         void* this_arg_ptr = untag_ptr(this_arg);
15318         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15319         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
15320         void* msg_ptr = untag_ptr(msg);
15321         CHECK_ACCESS(msg_ptr);
15322         LDKCustomOnionMessageContents msg_conv = *(LDKCustomOnionMessageContents*)(msg_ptr);
15323         if (msg_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
15324                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15325                 LDKCustomOnionMessageContents_JCalls_cloned(&msg_conv);
15326         }
15327         (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv);
15328 }
15329
15330 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) {
15331         void* this_arg_ptr = untag_ptr(this_arg);
15332         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15333         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
15334         LDKu8slice buffer_ref;
15335         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
15336         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
15337         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
15338         *ret_conv = (this_arg_conv->read_custom_message)(this_arg_conv->this_arg, message_type, buffer_ref);
15339         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
15340         return tag_ptr(ret_conv, true);
15341 }
15342
15343 typedef struct LDKSocketDescriptor_JCalls {
15344         atomic_size_t refcnt;
15345         JavaVM *vm;
15346         jweak o;
15347         jmethodID send_data_meth;
15348         jmethodID disconnect_socket_meth;
15349         jmethodID eq_meth;
15350         jmethodID hash_meth;
15351 } LDKSocketDescriptor_JCalls;
15352 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
15353         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
15354         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
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                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
15363                 if (get_jenv_res == JNI_EDETACHED) {
15364                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15365                 }
15366                 FREE(j_calls);
15367         }
15368 }
15369 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
15370         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
15371         JNIEnv *env;
15372         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15373         if (get_jenv_res == JNI_EDETACHED) {
15374                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15375         } else {
15376                 DO_ASSERT(get_jenv_res == JNI_OK);
15377         }
15378         LDKu8slice data_var = data;
15379         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
15380         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
15381         jboolean resume_read_conv = resume_read;
15382         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15383         CHECK(obj != NULL);
15384         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
15385         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15386                 (*env)->ExceptionDescribe(env);
15387                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
15388         }
15389         if (get_jenv_res == JNI_EDETACHED) {
15390                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15391         }
15392         return ret;
15393 }
15394 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
15395         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
15396         JNIEnv *env;
15397         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15398         if (get_jenv_res == JNI_EDETACHED) {
15399                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15400         } else {
15401                 DO_ASSERT(get_jenv_res == JNI_OK);
15402         }
15403         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15404         CHECK(obj != NULL);
15405         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
15406         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15407                 (*env)->ExceptionDescribe(env);
15408                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
15409         }
15410         if (get_jenv_res == JNI_EDETACHED) {
15411                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15412         }
15413 }
15414 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
15415         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
15416         JNIEnv *env;
15417         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15418         if (get_jenv_res == JNI_EDETACHED) {
15419                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15420         } else {
15421                 DO_ASSERT(get_jenv_res == JNI_OK);
15422         }
15423         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
15424         *other_arg_clone = SocketDescriptor_clone(other_arg);
15425         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15426         CHECK(obj != NULL);
15427         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, tag_ptr(other_arg_clone, true));
15428         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15429                 (*env)->ExceptionDescribe(env);
15430                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
15431         }
15432         if (get_jenv_res == JNI_EDETACHED) {
15433                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15434         }
15435         return ret;
15436 }
15437 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
15438         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
15439         JNIEnv *env;
15440         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15441         if (get_jenv_res == JNI_EDETACHED) {
15442                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15443         } else {
15444                 DO_ASSERT(get_jenv_res == JNI_OK);
15445         }
15446         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15447         CHECK(obj != NULL);
15448         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
15449         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15450                 (*env)->ExceptionDescribe(env);
15451                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
15452         }
15453         if (get_jenv_res == JNI_EDETACHED) {
15454                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15455         }
15456         return ret;
15457 }
15458 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
15459         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
15460         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15461 }
15462 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
15463         jclass c = (*env)->GetObjectClass(env, o);
15464         CHECK(c != NULL);
15465         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
15466         atomic_init(&calls->refcnt, 1);
15467         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15468         calls->o = (*env)->NewWeakGlobalRef(env, o);
15469         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
15470         CHECK(calls->send_data_meth != NULL);
15471         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
15472         CHECK(calls->disconnect_socket_meth != NULL);
15473         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
15474         CHECK(calls->eq_meth != NULL);
15475         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
15476         CHECK(calls->hash_meth != NULL);
15477
15478         LDKSocketDescriptor ret = {
15479                 .this_arg = (void*) calls,
15480                 .send_data = send_data_LDKSocketDescriptor_jcall,
15481                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
15482                 .eq = eq_LDKSocketDescriptor_jcall,
15483                 .hash = hash_LDKSocketDescriptor_jcall,
15484                 .cloned = LDKSocketDescriptor_JCalls_cloned,
15485                 .free = LDKSocketDescriptor_JCalls_free,
15486         };
15487         return ret;
15488 }
15489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
15490         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
15491         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
15492         return tag_ptr(res_ptr, true);
15493 }
15494 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) {
15495         void* this_arg_ptr = untag_ptr(this_arg);
15496         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15497         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
15498         LDKu8slice data_ref;
15499         data_ref.datalen = (*env)->GetArrayLength(env, data);
15500         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
15501         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
15502         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
15503         return ret_conv;
15504 }
15505
15506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
15507         void* this_arg_ptr = untag_ptr(this_arg);
15508         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15509         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
15510         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
15511 }
15512
15513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
15514         void* this_arg_ptr = untag_ptr(this_arg);
15515         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15516         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
15517         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
15518         return ret_conv;
15519 }
15520
15521 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
15522 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
15523 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
15524 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
15525 static jclass LDKEffectiveCapacity_Total_class = NULL;
15526 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
15527 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
15528 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
15529 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
15530 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
15531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
15532         LDKEffectiveCapacity_ExactLiquidity_class =
15533                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
15534         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
15535         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
15536         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
15537         LDKEffectiveCapacity_MaximumHTLC_class =
15538                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
15539         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
15540         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
15541         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
15542         LDKEffectiveCapacity_Total_class =
15543                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
15544         CHECK(LDKEffectiveCapacity_Total_class != NULL);
15545         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(JJ)V");
15546         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
15547         LDKEffectiveCapacity_Infinite_class =
15548                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
15549         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
15550         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
15551         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
15552         LDKEffectiveCapacity_Unknown_class =
15553                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
15554         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
15555         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
15556         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
15557 }
15558 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15559         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
15560         switch(obj->tag) {
15561                 case LDKEffectiveCapacity_ExactLiquidity: {
15562                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
15563                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
15564                 }
15565                 case LDKEffectiveCapacity_MaximumHTLC: {
15566                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
15567                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
15568                 }
15569                 case LDKEffectiveCapacity_Total: {
15570                         int64_t capacity_msat_conv = obj->total.capacity_msat;
15571                         int64_t htlc_maximum_msat_conv = obj->total.htlc_maximum_msat;
15572                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv, htlc_maximum_msat_conv);
15573                 }
15574                 case LDKEffectiveCapacity_Infinite: {
15575                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
15576                 }
15577                 case LDKEffectiveCapacity_Unknown: {
15578                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
15579                 }
15580                 default: abort();
15581         }
15582 }
15583 static jclass LDKDestination_Node_class = NULL;
15584 static jmethodID LDKDestination_Node_meth = NULL;
15585 static jclass LDKDestination_BlindedPath_class = NULL;
15586 static jmethodID LDKDestination_BlindedPath_meth = NULL;
15587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKDestination_init (JNIEnv *env, jclass clz) {
15588         LDKDestination_Node_class =
15589                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$Node"));
15590         CHECK(LDKDestination_Node_class != NULL);
15591         LDKDestination_Node_meth = (*env)->GetMethodID(env, LDKDestination_Node_class, "<init>", "([B)V");
15592         CHECK(LDKDestination_Node_meth != NULL);
15593         LDKDestination_BlindedPath_class =
15594                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$BlindedPath"));
15595         CHECK(LDKDestination_BlindedPath_class != NULL);
15596         LDKDestination_BlindedPath_meth = (*env)->GetMethodID(env, LDKDestination_BlindedPath_class, "<init>", "(J)V");
15597         CHECK(LDKDestination_BlindedPath_meth != NULL);
15598 }
15599 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15600         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
15601         switch(obj->tag) {
15602                 case LDKDestination_Node: {
15603                         int8_tArray node_arr = (*env)->NewByteArray(env, 33);
15604                         (*env)->SetByteArrayRegion(env, node_arr, 0, 33, obj->node.compressed_form);
15605                         return (*env)->NewObject(env, LDKDestination_Node_class, LDKDestination_Node_meth, node_arr);
15606                 }
15607                 case LDKDestination_BlindedPath: {
15608                         LDKBlindedPath blinded_path_var = obj->blinded_path;
15609                         int64_t blinded_path_ref = 0;
15610                         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_path_var);
15611                         blinded_path_ref = tag_ptr(blinded_path_var.inner, false);
15612                         return (*env)->NewObject(env, LDKDestination_BlindedPath_class, LDKDestination_BlindedPath_meth, blinded_path_ref);
15613                 }
15614                 default: abort();
15615         }
15616 }
15617 static jclass LDKOnionMessageContents_Custom_class = NULL;
15618 static jmethodID LDKOnionMessageContents_Custom_meth = NULL;
15619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKOnionMessageContents_init (JNIEnv *env, jclass clz) {
15620         LDKOnionMessageContents_Custom_class =
15621                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKOnionMessageContents$Custom"));
15622         CHECK(LDKOnionMessageContents_Custom_class != NULL);
15623         LDKOnionMessageContents_Custom_meth = (*env)->GetMethodID(env, LDKOnionMessageContents_Custom_class, "<init>", "(J)V");
15624         CHECK(LDKOnionMessageContents_Custom_meth != NULL);
15625 }
15626 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageContents_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15627         LDKOnionMessageContents *obj = (LDKOnionMessageContents*)untag_ptr(ptr);
15628         switch(obj->tag) {
15629                 case LDKOnionMessageContents_Custom: {
15630                         LDKCustomOnionMessageContents* custom_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
15631                         *custom_ret = CustomOnionMessageContents_clone(&obj->custom);
15632                         return (*env)->NewObject(env, LDKOnionMessageContents_Custom_class, LDKOnionMessageContents_Custom_meth, tag_ptr(custom_ret, true));
15633                 }
15634                 default: abort();
15635         }
15636 }
15637 static jclass LDKGossipSync_P2P_class = NULL;
15638 static jmethodID LDKGossipSync_P2P_meth = NULL;
15639 static jclass LDKGossipSync_Rapid_class = NULL;
15640 static jmethodID LDKGossipSync_Rapid_meth = NULL;
15641 static jclass LDKGossipSync_None_class = NULL;
15642 static jmethodID LDKGossipSync_None_meth = NULL;
15643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGossipSync_init (JNIEnv *env, jclass clz) {
15644         LDKGossipSync_P2P_class =
15645                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$P2P"));
15646         CHECK(LDKGossipSync_P2P_class != NULL);
15647         LDKGossipSync_P2P_meth = (*env)->GetMethodID(env, LDKGossipSync_P2P_class, "<init>", "(J)V");
15648         CHECK(LDKGossipSync_P2P_meth != NULL);
15649         LDKGossipSync_Rapid_class =
15650                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$Rapid"));
15651         CHECK(LDKGossipSync_Rapid_class != NULL);
15652         LDKGossipSync_Rapid_meth = (*env)->GetMethodID(env, LDKGossipSync_Rapid_class, "<init>", "(J)V");
15653         CHECK(LDKGossipSync_Rapid_meth != NULL);
15654         LDKGossipSync_None_class =
15655                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$None"));
15656         CHECK(LDKGossipSync_None_class != NULL);
15657         LDKGossipSync_None_meth = (*env)->GetMethodID(env, LDKGossipSync_None_class, "<init>", "()V");
15658         CHECK(LDKGossipSync_None_meth != NULL);
15659 }
15660 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGossipSync_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15661         LDKGossipSync *obj = (LDKGossipSync*)untag_ptr(ptr);
15662         switch(obj->tag) {
15663                 case LDKGossipSync_P2P: {
15664                         LDKP2PGossipSync p2p_var = obj->p2p;
15665                         int64_t p2p_ref = 0;
15666                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
15667                         p2p_ref = tag_ptr(p2p_var.inner, false);
15668                         return (*env)->NewObject(env, LDKGossipSync_P2P_class, LDKGossipSync_P2P_meth, p2p_ref);
15669                 }
15670                 case LDKGossipSync_Rapid: {
15671                         LDKRapidGossipSync rapid_var = obj->rapid;
15672                         int64_t rapid_ref = 0;
15673                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
15674                         rapid_ref = tag_ptr(rapid_var.inner, false);
15675                         return (*env)->NewObject(env, LDKGossipSync_Rapid_class, LDKGossipSync_Rapid_meth, rapid_ref);
15676                 }
15677                 case LDKGossipSync_None: {
15678                         return (*env)->NewObject(env, LDKGossipSync_None_class, LDKGossipSync_None_meth);
15679                 }
15680                 default: abort();
15681         }
15682 }
15683 static jclass LDKFallback_SegWitProgram_class = NULL;
15684 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
15685 static jclass LDKFallback_PubKeyHash_class = NULL;
15686 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
15687 static jclass LDKFallback_ScriptHash_class = NULL;
15688 static jmethodID LDKFallback_ScriptHash_meth = NULL;
15689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
15690         LDKFallback_SegWitProgram_class =
15691                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
15692         CHECK(LDKFallback_SegWitProgram_class != NULL);
15693         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
15694         CHECK(LDKFallback_SegWitProgram_meth != NULL);
15695         LDKFallback_PubKeyHash_class =
15696                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
15697         CHECK(LDKFallback_PubKeyHash_class != NULL);
15698         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
15699         CHECK(LDKFallback_PubKeyHash_meth != NULL);
15700         LDKFallback_ScriptHash_class =
15701                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
15702         CHECK(LDKFallback_ScriptHash_class != NULL);
15703         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
15704         CHECK(LDKFallback_ScriptHash_meth != NULL);
15705 }
15706 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15707         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
15708         switch(obj->tag) {
15709                 case LDKFallback_SegWitProgram: {
15710                         uint8_t version_val = obj->seg_wit_program.version._0;
15711                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
15712                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
15713                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
15714                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
15715                 }
15716                 case LDKFallback_PubKeyHash: {
15717                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
15718                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
15719                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
15720                 }
15721                 case LDKFallback_ScriptHash: {
15722                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
15723                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
15724                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
15725                 }
15726                 default: abort();
15727         }
15728 }
15729 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
15730         LDKStr ret_str = _ldk_get_compiled_version();
15731         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
15732         Str_free(ret_str);
15733         return ret_conv;
15734 }
15735
15736 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
15737         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
15738         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
15739         Str_free(ret_str);
15740         return ret_conv;
15741 }
15742
15743 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_U128_1le_1bytes(JNIEnv *env, jclass clz, int8_tArray val) {
15744         LDKU128 val_ref;
15745         CHECK((*env)->GetArrayLength(env, val) == 16);
15746         (*env)->GetByteArrayRegion(env, val, 0, 16, val_ref.le_bytes);
15747         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
15748         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, U128_le_bytes(val_ref).data);
15749         return ret_arr;
15750 }
15751
15752 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_U128_1new(JNIEnv *env, jclass clz, int8_tArray le_bytes) {
15753         LDKSixteenBytes le_bytes_ref;
15754         CHECK((*env)->GetArrayLength(env, le_bytes) == 16);
15755         (*env)->GetByteArrayRegion(env, le_bytes, 0, 16, le_bytes_ref.data);
15756         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
15757         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, U128_new(le_bytes_ref).le_bytes);
15758         return ret_arr;
15759 }
15760
15761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1new(JNIEnv *env, jclass clz, int8_tArray big_endian_bytes) {
15762         LDKThirtyTwoBytes big_endian_bytes_ref;
15763         CHECK((*env)->GetArrayLength(env, big_endian_bytes) == 32);
15764         (*env)->GetByteArrayRegion(env, big_endian_bytes, 0, 32, big_endian_bytes_ref.data);
15765         LDKBigEndianScalar* ret_ref = MALLOC(sizeof(LDKBigEndianScalar), "LDKBigEndianScalar");
15766         *ret_ref = BigEndianScalar_new(big_endian_bytes_ref);
15767         return tag_ptr(ret_ref, true);
15768 }
15769
15770 static inline uint64_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
15771         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15772         *ret_copy = Bech32Error_clone(arg);
15773         int64_t ret_ref = tag_ptr(ret_copy, true);
15774         return ret_ref;
15775 }
15776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15777         LDKBech32Error* arg_conv = (LDKBech32Error*)untag_ptr(arg);
15778         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
15779         return ret_conv;
15780 }
15781
15782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15783         LDKBech32Error* orig_conv = (LDKBech32Error*)untag_ptr(orig);
15784         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15785         *ret_copy = Bech32Error_clone(orig_conv);
15786         int64_t ret_ref = tag_ptr(ret_copy, true);
15787         return ret_ref;
15788 }
15789
15790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
15791         if (!ptr_is_owned(o)) return;
15792         void* o_ptr = untag_ptr(o);
15793         CHECK_ACCESS(o_ptr);
15794         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
15795         FREE(untag_ptr(o));
15796         Bech32Error_free(o_conv);
15797 }
15798
15799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
15800         LDKTransaction _res_ref;
15801         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
15802         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
15803         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
15804         _res_ref.data_is_owned = true;
15805         Transaction_free(_res_ref);
15806 }
15807
15808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Witness_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
15809         LDKWitness _res_ref;
15810         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
15811         _res_ref.data = MALLOC(_res_ref.datalen, "LDKWitness Bytes");
15812         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
15813         _res_ref.data_is_owned = true;
15814         Witness_free(_res_ref);
15815 }
15816
15817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
15818         LDKCVec_u8Z script_pubkey_ref;
15819         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
15820         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
15821         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
15822         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15823         *ret_ref = TxOut_new(script_pubkey_ref, value);
15824         return tag_ptr(ret_ref, true);
15825 }
15826
15827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
15828         if (!ptr_is_owned(_res)) return;
15829         void* _res_ptr = untag_ptr(_res);
15830         CHECK_ACCESS(_res_ptr);
15831         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
15832         FREE(untag_ptr(_res));
15833         TxOut_free(_res_conv);
15834 }
15835
15836 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
15837         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15838         *ret_ref = TxOut_clone(arg);
15839         return tag_ptr(ret_ref, true);
15840 }
15841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15842         LDKTxOut* arg_conv = (LDKTxOut*)untag_ptr(arg);
15843         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
15844         return ret_conv;
15845 }
15846
15847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15848         LDKTxOut* orig_conv = (LDKTxOut*)untag_ptr(orig);
15849         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15850         *ret_ref = TxOut_clone(orig_conv);
15851         return tag_ptr(ret_ref, true);
15852 }
15853
15854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
15855         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
15856         Str_free(dummy);
15857 }
15858
15859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
15860         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15861         *ret_conv = CResult_NoneAPIErrorZ_ok();
15862         return tag_ptr(ret_conv, true);
15863 }
15864
15865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15866         void* e_ptr = untag_ptr(e);
15867         CHECK_ACCESS(e_ptr);
15868         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15869         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
15870         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15871         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
15872         return tag_ptr(ret_conv, true);
15873 }
15874
15875 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15876         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(o);
15877         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
15878         return ret_conv;
15879 }
15880
15881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15882         if (!ptr_is_owned(_res)) return;
15883         void* _res_ptr = untag_ptr(_res);
15884         CHECK_ACCESS(_res_ptr);
15885         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
15886         FREE(untag_ptr(_res));
15887         CResult_NoneAPIErrorZ_free(_res_conv);
15888 }
15889
15890 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
15891         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15892         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
15893         return tag_ptr(ret_conv, true);
15894 }
15895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15896         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(arg);
15897         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
15898         return ret_conv;
15899 }
15900
15901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15902         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(orig);
15903         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15904         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
15905         return tag_ptr(ret_conv, true);
15906 }
15907
15908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15909         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
15910         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15911         if (_res_constr.datalen > 0)
15912                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15913         else
15914                 _res_constr.data = NULL;
15915         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15916         for (size_t w = 0; w < _res_constr.datalen; w++) {
15917                 int64_t _res_conv_22 = _res_vals[w];
15918                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
15919                 CHECK_ACCESS(_res_conv_22_ptr);
15920                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
15921                 FREE(untag_ptr(_res_conv_22));
15922                 _res_constr.data[w] = _res_conv_22_conv;
15923         }
15924         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15925         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
15926 }
15927
15928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15929         LDKCVec_APIErrorZ _res_constr;
15930         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15931         if (_res_constr.datalen > 0)
15932                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
15933         else
15934                 _res_constr.data = NULL;
15935         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15936         for (size_t k = 0; k < _res_constr.datalen; k++) {
15937                 int64_t _res_conv_10 = _res_vals[k];
15938                 void* _res_conv_10_ptr = untag_ptr(_res_conv_10);
15939                 CHECK_ACCESS(_res_conv_10_ptr);
15940                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
15941                 FREE(untag_ptr(_res_conv_10));
15942                 _res_constr.data[k] = _res_conv_10_conv;
15943         }
15944         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15945         CVec_APIErrorZ_free(_res_constr);
15946 }
15947
15948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCClaimZ_1some(JNIEnv *env, jclass clz, jclass o) {
15949         LDKHTLCClaim o_conv = LDKHTLCClaim_from_java(env, o);
15950         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
15951         *ret_copy = COption_HTLCClaimZ_some(o_conv);
15952         int64_t ret_ref = tag_ptr(ret_copy, true);
15953         return ret_ref;
15954 }
15955
15956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCClaimZ_1none(JNIEnv *env, jclass clz) {
15957         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
15958         *ret_copy = COption_HTLCClaimZ_none();
15959         int64_t ret_ref = tag_ptr(ret_copy, true);
15960         return ret_ref;
15961 }
15962
15963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCClaimZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15964         if (!ptr_is_owned(_res)) return;
15965         void* _res_ptr = untag_ptr(_res);
15966         CHECK_ACCESS(_res_ptr);
15967         LDKCOption_HTLCClaimZ _res_conv = *(LDKCOption_HTLCClaimZ*)(_res_ptr);
15968         FREE(untag_ptr(_res));
15969         COption_HTLCClaimZ_free(_res_conv);
15970 }
15971
15972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
15973         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15974         *ret_conv = CResult_NoneNoneZ_ok();
15975         return tag_ptr(ret_conv, true);
15976 }
15977
15978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
15979         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15980         *ret_conv = CResult_NoneNoneZ_err();
15981         return tag_ptr(ret_conv, true);
15982 }
15983
15984 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15985         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)untag_ptr(o);
15986         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
15987         return ret_conv;
15988 }
15989
15990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15991         if (!ptr_is_owned(_res)) return;
15992         void* _res_ptr = untag_ptr(_res);
15993         CHECK_ACCESS(_res_ptr);
15994         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
15995         FREE(untag_ptr(_res));
15996         CResult_NoneNoneZ_free(_res_conv);
15997 }
15998
15999 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
16000         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16001         *ret_conv = CResult_NoneNoneZ_clone(arg);
16002         return tag_ptr(ret_conv, true);
16003 }
16004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16005         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)untag_ptr(arg);
16006         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
16007         return ret_conv;
16008 }
16009
16010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16011         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)untag_ptr(orig);
16012         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16013         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
16014         return tag_ptr(ret_conv, true);
16015 }
16016
16017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16018         LDKCounterpartyCommitmentSecrets o_conv;
16019         o_conv.inner = untag_ptr(o);
16020         o_conv.is_owned = ptr_is_owned(o);
16021         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16022         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
16023         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16024         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
16025         return tag_ptr(ret_conv, true);
16026 }
16027
16028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16029         void* e_ptr = untag_ptr(e);
16030         CHECK_ACCESS(e_ptr);
16031         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16032         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16033         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16034         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
16035         return tag_ptr(ret_conv, true);
16036 }
16037
16038 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16039         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(o);
16040         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
16041         return ret_conv;
16042 }
16043
16044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16045         if (!ptr_is_owned(_res)) return;
16046         void* _res_ptr = untag_ptr(_res);
16047         CHECK_ACCESS(_res_ptr);
16048         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
16049         FREE(untag_ptr(_res));
16050         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
16051 }
16052
16053 static inline uint64_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
16054         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16055         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
16056         return tag_ptr(ret_conv, true);
16057 }
16058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16059         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(arg);
16060         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
16061         return ret_conv;
16062 }
16063
16064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16065         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(orig);
16066         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16067         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
16068         return tag_ptr(ret_conv, true);
16069 }
16070
16071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16072         LDKTxCreationKeys o_conv;
16073         o_conv.inner = untag_ptr(o);
16074         o_conv.is_owned = ptr_is_owned(o);
16075         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16076         o_conv = TxCreationKeys_clone(&o_conv);
16077         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16078         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
16079         return tag_ptr(ret_conv, true);
16080 }
16081
16082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16083         void* e_ptr = untag_ptr(e);
16084         CHECK_ACCESS(e_ptr);
16085         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16086         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16087         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16088         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
16089         return tag_ptr(ret_conv, true);
16090 }
16091
16092 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16093         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(o);
16094         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
16095         return ret_conv;
16096 }
16097
16098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16099         if (!ptr_is_owned(_res)) return;
16100         void* _res_ptr = untag_ptr(_res);
16101         CHECK_ACCESS(_res_ptr);
16102         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
16103         FREE(untag_ptr(_res));
16104         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
16105 }
16106
16107 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
16108         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16109         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
16110         return tag_ptr(ret_conv, true);
16111 }
16112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16113         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(arg);
16114         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
16115         return ret_conv;
16116 }
16117
16118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16119         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(orig);
16120         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16121         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
16122         return tag_ptr(ret_conv, true);
16123 }
16124
16125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16126         LDKChannelPublicKeys o_conv;
16127         o_conv.inner = untag_ptr(o);
16128         o_conv.is_owned = ptr_is_owned(o);
16129         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16130         o_conv = ChannelPublicKeys_clone(&o_conv);
16131         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16132         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
16133         return tag_ptr(ret_conv, true);
16134 }
16135
16136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16137         void* e_ptr = untag_ptr(e);
16138         CHECK_ACCESS(e_ptr);
16139         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16140         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16141         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16142         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
16143         return tag_ptr(ret_conv, true);
16144 }
16145
16146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16147         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(o);
16148         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
16149         return ret_conv;
16150 }
16151
16152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16153         if (!ptr_is_owned(_res)) return;
16154         void* _res_ptr = untag_ptr(_res);
16155         CHECK_ACCESS(_res_ptr);
16156         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
16157         FREE(untag_ptr(_res));
16158         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
16159 }
16160
16161 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
16162         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16163         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
16164         return tag_ptr(ret_conv, true);
16165 }
16166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16167         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(arg);
16168         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
16169         return ret_conv;
16170 }
16171
16172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16173         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(orig);
16174         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16175         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
16176         return tag_ptr(ret_conv, true);
16177 }
16178
16179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
16180         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16181         *ret_copy = COption_u32Z_some(o);
16182         int64_t ret_ref = tag_ptr(ret_copy, true);
16183         return ret_ref;
16184 }
16185
16186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
16187         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16188         *ret_copy = COption_u32Z_none();
16189         int64_t ret_ref = tag_ptr(ret_copy, true);
16190         return ret_ref;
16191 }
16192
16193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16194         if (!ptr_is_owned(_res)) return;
16195         void* _res_ptr = untag_ptr(_res);
16196         CHECK_ACCESS(_res_ptr);
16197         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
16198         FREE(untag_ptr(_res));
16199         COption_u32Z_free(_res_conv);
16200 }
16201
16202 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
16203         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16204         *ret_copy = COption_u32Z_clone(arg);
16205         int64_t ret_ref = tag_ptr(ret_copy, true);
16206         return ret_ref;
16207 }
16208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16209         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)untag_ptr(arg);
16210         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
16211         return ret_conv;
16212 }
16213
16214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16215         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)untag_ptr(orig);
16216         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16217         *ret_copy = COption_u32Z_clone(orig_conv);
16218         int64_t ret_ref = tag_ptr(ret_copy, true);
16219         return ret_ref;
16220 }
16221
16222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16223         LDKHTLCOutputInCommitment o_conv;
16224         o_conv.inner = untag_ptr(o);
16225         o_conv.is_owned = ptr_is_owned(o);
16226         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16227         o_conv = HTLCOutputInCommitment_clone(&o_conv);
16228         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16229         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
16230         return tag_ptr(ret_conv, true);
16231 }
16232
16233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16234         void* e_ptr = untag_ptr(e);
16235         CHECK_ACCESS(e_ptr);
16236         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16237         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16238         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16239         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
16240         return tag_ptr(ret_conv, true);
16241 }
16242
16243 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16244         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(o);
16245         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
16246         return ret_conv;
16247 }
16248
16249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16250         if (!ptr_is_owned(_res)) return;
16251         void* _res_ptr = untag_ptr(_res);
16252         CHECK_ACCESS(_res_ptr);
16253         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
16254         FREE(untag_ptr(_res));
16255         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
16256 }
16257
16258 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
16259         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16260         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
16261         return tag_ptr(ret_conv, true);
16262 }
16263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16264         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(arg);
16265         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
16266         return ret_conv;
16267 }
16268
16269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16270         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(orig);
16271         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16272         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
16273         return tag_ptr(ret_conv, true);
16274 }
16275
16276 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
16277         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
16278         return ret_conv;
16279 }
16280
16281 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
16282         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
16283         return ret_conv;
16284 }
16285
16286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
16287         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
16288         COption_NoneZ_free(_res_conv);
16289 }
16290
16291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16292         LDKCounterpartyChannelTransactionParameters o_conv;
16293         o_conv.inner = untag_ptr(o);
16294         o_conv.is_owned = ptr_is_owned(o);
16295         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16296         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
16297         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16298         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
16299         return tag_ptr(ret_conv, true);
16300 }
16301
16302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16303         void* e_ptr = untag_ptr(e);
16304         CHECK_ACCESS(e_ptr);
16305         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16306         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16307         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16308         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
16309         return tag_ptr(ret_conv, true);
16310 }
16311
16312 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16313         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
16314         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
16315         return ret_conv;
16316 }
16317
16318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16319         if (!ptr_is_owned(_res)) return;
16320         void* _res_ptr = untag_ptr(_res);
16321         CHECK_ACCESS(_res_ptr);
16322         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
16323         FREE(untag_ptr(_res));
16324         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
16325 }
16326
16327 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
16328         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16329         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
16330         return tag_ptr(ret_conv, true);
16331 }
16332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16333         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
16334         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
16335         return ret_conv;
16336 }
16337
16338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16339         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
16340         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16341         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
16342         return tag_ptr(ret_conv, true);
16343 }
16344
16345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16346         LDKChannelTransactionParameters o_conv;
16347         o_conv.inner = untag_ptr(o);
16348         o_conv.is_owned = ptr_is_owned(o);
16349         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16350         o_conv = ChannelTransactionParameters_clone(&o_conv);
16351         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16352         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
16353         return tag_ptr(ret_conv, true);
16354 }
16355
16356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16357         void* e_ptr = untag_ptr(e);
16358         CHECK_ACCESS(e_ptr);
16359         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16360         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16361         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16362         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
16363         return tag_ptr(ret_conv, true);
16364 }
16365
16366 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16367         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
16368         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
16369         return ret_conv;
16370 }
16371
16372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16373         if (!ptr_is_owned(_res)) return;
16374         void* _res_ptr = untag_ptr(_res);
16375         CHECK_ACCESS(_res_ptr);
16376         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
16377         FREE(untag_ptr(_res));
16378         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
16379 }
16380
16381 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
16382         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16383         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
16384         return tag_ptr(ret_conv, true);
16385 }
16386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16387         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
16388         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
16389         return ret_conv;
16390 }
16391
16392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16393         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
16394         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16395         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
16396         return tag_ptr(ret_conv, true);
16397 }
16398
16399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16400         LDKCVec_SignatureZ _res_constr;
16401         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16402         if (_res_constr.datalen > 0)
16403                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16404         else
16405                 _res_constr.data = NULL;
16406         for (size_t i = 0; i < _res_constr.datalen; i++) {
16407                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16408                 LDKSignature _res_conv_8_ref;
16409                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
16410                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
16411                 _res_constr.data[i] = _res_conv_8_ref;
16412         }
16413         CVec_SignatureZ_free(_res_constr);
16414 }
16415
16416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16417         LDKHolderCommitmentTransaction o_conv;
16418         o_conv.inner = untag_ptr(o);
16419         o_conv.is_owned = ptr_is_owned(o);
16420         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16421         o_conv = HolderCommitmentTransaction_clone(&o_conv);
16422         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16423         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
16424         return tag_ptr(ret_conv, true);
16425 }
16426
16427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16428         void* e_ptr = untag_ptr(e);
16429         CHECK_ACCESS(e_ptr);
16430         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16431         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16432         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16433         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
16434         return tag_ptr(ret_conv, true);
16435 }
16436
16437 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16438         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16439         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16440         return ret_conv;
16441 }
16442
16443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16444         if (!ptr_is_owned(_res)) return;
16445         void* _res_ptr = untag_ptr(_res);
16446         CHECK_ACCESS(_res_ptr);
16447         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
16448         FREE(untag_ptr(_res));
16449         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
16450 }
16451
16452 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16453         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16454         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
16455         return tag_ptr(ret_conv, true);
16456 }
16457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16458         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16459         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16460         return ret_conv;
16461 }
16462
16463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16464         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16465         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16466         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
16467         return tag_ptr(ret_conv, true);
16468 }
16469
16470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16471         LDKBuiltCommitmentTransaction o_conv;
16472         o_conv.inner = untag_ptr(o);
16473         o_conv.is_owned = ptr_is_owned(o);
16474         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16475         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
16476         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16477         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
16478         return tag_ptr(ret_conv, true);
16479 }
16480
16481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16482         void* e_ptr = untag_ptr(e);
16483         CHECK_ACCESS(e_ptr);
16484         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16485         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16486         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16487         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
16488         return tag_ptr(ret_conv, true);
16489 }
16490
16491 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16492         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16493         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16494         return ret_conv;
16495 }
16496
16497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16498         if (!ptr_is_owned(_res)) return;
16499         void* _res_ptr = untag_ptr(_res);
16500         CHECK_ACCESS(_res_ptr);
16501         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
16502         FREE(untag_ptr(_res));
16503         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
16504 }
16505
16506 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16507         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16508         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
16509         return tag_ptr(ret_conv, true);
16510 }
16511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16512         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16513         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16514         return ret_conv;
16515 }
16516
16517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16518         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16519         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16520         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
16521         return tag_ptr(ret_conv, true);
16522 }
16523
16524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16525         LDKTrustedClosingTransaction o_conv;
16526         o_conv.inner = untag_ptr(o);
16527         o_conv.is_owned = ptr_is_owned(o);
16528         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16529         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
16530         
16531         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
16532         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
16533         return tag_ptr(ret_conv, true);
16534 }
16535
16536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
16537         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
16538         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
16539         return tag_ptr(ret_conv, true);
16540 }
16541
16542 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16543         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(o);
16544         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
16545         return ret_conv;
16546 }
16547
16548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16549         if (!ptr_is_owned(_res)) return;
16550         void* _res_ptr = untag_ptr(_res);
16551         CHECK_ACCESS(_res_ptr);
16552         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
16553         FREE(untag_ptr(_res));
16554         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
16555 }
16556
16557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16558         LDKCommitmentTransaction o_conv;
16559         o_conv.inner = untag_ptr(o);
16560         o_conv.is_owned = ptr_is_owned(o);
16561         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16562         o_conv = CommitmentTransaction_clone(&o_conv);
16563         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16564         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
16565         return tag_ptr(ret_conv, true);
16566 }
16567
16568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16569         void* e_ptr = untag_ptr(e);
16570         CHECK_ACCESS(e_ptr);
16571         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16572         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16573         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16574         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
16575         return tag_ptr(ret_conv, true);
16576 }
16577
16578 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16579         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16580         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16581         return ret_conv;
16582 }
16583
16584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16585         if (!ptr_is_owned(_res)) return;
16586         void* _res_ptr = untag_ptr(_res);
16587         CHECK_ACCESS(_res_ptr);
16588         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
16589         FREE(untag_ptr(_res));
16590         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
16591 }
16592
16593 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16594         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16595         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
16596         return tag_ptr(ret_conv, true);
16597 }
16598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16599         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16600         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16601         return ret_conv;
16602 }
16603
16604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16605         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16606         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16607         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
16608         return tag_ptr(ret_conv, true);
16609 }
16610
16611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16612         LDKTrustedCommitmentTransaction o_conv;
16613         o_conv.inner = untag_ptr(o);
16614         o_conv.is_owned = ptr_is_owned(o);
16615         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16616         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
16617         
16618         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
16619         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
16620         return tag_ptr(ret_conv, true);
16621 }
16622
16623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
16624         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
16625         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
16626         return tag_ptr(ret_conv, true);
16627 }
16628
16629 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16630         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(o);
16631         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
16632         return ret_conv;
16633 }
16634
16635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16636         if (!ptr_is_owned(_res)) return;
16637         void* _res_ptr = untag_ptr(_res);
16638         CHECK_ACCESS(_res_ptr);
16639         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
16640         FREE(untag_ptr(_res));
16641         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
16642 }
16643
16644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
16645         LDKCVec_SignatureZ o_constr;
16646         o_constr.datalen = (*env)->GetArrayLength(env, o);
16647         if (o_constr.datalen > 0)
16648                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16649         else
16650                 o_constr.data = NULL;
16651         for (size_t i = 0; i < o_constr.datalen; i++) {
16652                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
16653                 LDKSignature o_conv_8_ref;
16654                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
16655                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
16656                 o_constr.data[i] = o_conv_8_ref;
16657         }
16658         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16659         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
16660         return tag_ptr(ret_conv, true);
16661 }
16662
16663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
16664         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16665         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
16666         return tag_ptr(ret_conv, true);
16667 }
16668
16669 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16670         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(o);
16671         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
16672         return ret_conv;
16673 }
16674
16675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16676         if (!ptr_is_owned(_res)) return;
16677         void* _res_ptr = untag_ptr(_res);
16678         CHECK_ACCESS(_res_ptr);
16679         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
16680         FREE(untag_ptr(_res));
16681         CResult_CVec_SignatureZNoneZ_free(_res_conv);
16682 }
16683
16684 static inline uint64_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
16685         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16686         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
16687         return tag_ptr(ret_conv, true);
16688 }
16689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16690         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(arg);
16691         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
16692         return ret_conv;
16693 }
16694
16695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16696         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(orig);
16697         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16698         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
16699         return tag_ptr(ret_conv, true);
16700 }
16701
16702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16703         LDKShutdownScript o_conv;
16704         o_conv.inner = untag_ptr(o);
16705         o_conv.is_owned = ptr_is_owned(o);
16706         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16707         o_conv = ShutdownScript_clone(&o_conv);
16708         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16709         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
16710         return tag_ptr(ret_conv, true);
16711 }
16712
16713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16714         void* e_ptr = untag_ptr(e);
16715         CHECK_ACCESS(e_ptr);
16716         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16717         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16718         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16719         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
16720         return tag_ptr(ret_conv, true);
16721 }
16722
16723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16724         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(o);
16725         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
16726         return ret_conv;
16727 }
16728
16729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16730         if (!ptr_is_owned(_res)) return;
16731         void* _res_ptr = untag_ptr(_res);
16732         CHECK_ACCESS(_res_ptr);
16733         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
16734         FREE(untag_ptr(_res));
16735         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
16736 }
16737
16738 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
16739         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16740         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
16741         return tag_ptr(ret_conv, true);
16742 }
16743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16744         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(arg);
16745         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
16746         return ret_conv;
16747 }
16748
16749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16750         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(orig);
16751         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16752         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
16753         return tag_ptr(ret_conv, true);
16754 }
16755
16756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16757         LDKShutdownScript o_conv;
16758         o_conv.inner = untag_ptr(o);
16759         o_conv.is_owned = ptr_is_owned(o);
16760         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16761         o_conv = ShutdownScript_clone(&o_conv);
16762         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16763         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
16764         return tag_ptr(ret_conv, true);
16765 }
16766
16767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16768         LDKInvalidShutdownScript e_conv;
16769         e_conv.inner = untag_ptr(e);
16770         e_conv.is_owned = ptr_is_owned(e);
16771         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16772         e_conv = InvalidShutdownScript_clone(&e_conv);
16773         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16774         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
16775         return tag_ptr(ret_conv, true);
16776 }
16777
16778 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16779         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(o);
16780         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
16781         return ret_conv;
16782 }
16783
16784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16785         if (!ptr_is_owned(_res)) return;
16786         void* _res_ptr = untag_ptr(_res);
16787         CHECK_ACCESS(_res_ptr);
16788         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
16789         FREE(untag_ptr(_res));
16790         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
16791 }
16792
16793 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
16794         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16795         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
16796         return tag_ptr(ret_conv, true);
16797 }
16798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16799         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(arg);
16800         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
16801         return ret_conv;
16802 }
16803
16804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16805         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(orig);
16806         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16807         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
16808         return tag_ptr(ret_conv, true);
16809 }
16810
16811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16812         LDKCVec_PublicKeyZ _res_constr;
16813         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16814         if (_res_constr.datalen > 0)
16815                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16816         else
16817                 _res_constr.data = NULL;
16818         for (size_t i = 0; i < _res_constr.datalen; i++) {
16819                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16820                 LDKPublicKey _res_conv_8_ref;
16821                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
16822                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
16823                 _res_constr.data[i] = _res_conv_8_ref;
16824         }
16825         CVec_PublicKeyZ_free(_res_constr);
16826 }
16827
16828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16829         LDKBlindedPath o_conv;
16830         o_conv.inner = untag_ptr(o);
16831         o_conv.is_owned = ptr_is_owned(o);
16832         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16833         o_conv = BlindedPath_clone(&o_conv);
16834         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
16835         *ret_conv = CResult_BlindedPathNoneZ_ok(o_conv);
16836         return tag_ptr(ret_conv, true);
16837 }
16838
16839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1err(JNIEnv *env, jclass clz) {
16840         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
16841         *ret_conv = CResult_BlindedPathNoneZ_err();
16842         return tag_ptr(ret_conv, true);
16843 }
16844
16845 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16846         LDKCResult_BlindedPathNoneZ* o_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(o);
16847         jboolean ret_conv = CResult_BlindedPathNoneZ_is_ok(o_conv);
16848         return ret_conv;
16849 }
16850
16851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16852         if (!ptr_is_owned(_res)) return;
16853         void* _res_ptr = untag_ptr(_res);
16854         CHECK_ACCESS(_res_ptr);
16855         LDKCResult_BlindedPathNoneZ _res_conv = *(LDKCResult_BlindedPathNoneZ*)(_res_ptr);
16856         FREE(untag_ptr(_res));
16857         CResult_BlindedPathNoneZ_free(_res_conv);
16858 }
16859
16860 static inline uint64_t CResult_BlindedPathNoneZ_clone_ptr(LDKCResult_BlindedPathNoneZ *NONNULL_PTR arg) {
16861         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
16862         *ret_conv = CResult_BlindedPathNoneZ_clone(arg);
16863         return tag_ptr(ret_conv, true);
16864 }
16865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16866         LDKCResult_BlindedPathNoneZ* arg_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(arg);
16867         int64_t ret_conv = CResult_BlindedPathNoneZ_clone_ptr(arg_conv);
16868         return ret_conv;
16869 }
16870
16871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16872         LDKCResult_BlindedPathNoneZ* orig_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(orig);
16873         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
16874         *ret_conv = CResult_BlindedPathNoneZ_clone(orig_conv);
16875         return tag_ptr(ret_conv, true);
16876 }
16877
16878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16879         LDKBlindedPath o_conv;
16880         o_conv.inner = untag_ptr(o);
16881         o_conv.is_owned = ptr_is_owned(o);
16882         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16883         o_conv = BlindedPath_clone(&o_conv);
16884         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
16885         *ret_conv = CResult_BlindedPathDecodeErrorZ_ok(o_conv);
16886         return tag_ptr(ret_conv, true);
16887 }
16888
16889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16890         void* e_ptr = untag_ptr(e);
16891         CHECK_ACCESS(e_ptr);
16892         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16893         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16894         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
16895         *ret_conv = CResult_BlindedPathDecodeErrorZ_err(e_conv);
16896         return tag_ptr(ret_conv, true);
16897 }
16898
16899 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16900         LDKCResult_BlindedPathDecodeErrorZ* o_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(o);
16901         jboolean ret_conv = CResult_BlindedPathDecodeErrorZ_is_ok(o_conv);
16902         return ret_conv;
16903 }
16904
16905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16906         if (!ptr_is_owned(_res)) return;
16907         void* _res_ptr = untag_ptr(_res);
16908         CHECK_ACCESS(_res_ptr);
16909         LDKCResult_BlindedPathDecodeErrorZ _res_conv = *(LDKCResult_BlindedPathDecodeErrorZ*)(_res_ptr);
16910         FREE(untag_ptr(_res));
16911         CResult_BlindedPathDecodeErrorZ_free(_res_conv);
16912 }
16913
16914 static inline uint64_t CResult_BlindedPathDecodeErrorZ_clone_ptr(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR arg) {
16915         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
16916         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(arg);
16917         return tag_ptr(ret_conv, true);
16918 }
16919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16920         LDKCResult_BlindedPathDecodeErrorZ* arg_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(arg);
16921         int64_t ret_conv = CResult_BlindedPathDecodeErrorZ_clone_ptr(arg_conv);
16922         return ret_conv;
16923 }
16924
16925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16926         LDKCResult_BlindedPathDecodeErrorZ* orig_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(orig);
16927         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
16928         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(orig_conv);
16929         return tag_ptr(ret_conv, true);
16930 }
16931
16932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16933         LDKBlindedHop o_conv;
16934         o_conv.inner = untag_ptr(o);
16935         o_conv.is_owned = ptr_is_owned(o);
16936         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16937         o_conv = BlindedHop_clone(&o_conv);
16938         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
16939         *ret_conv = CResult_BlindedHopDecodeErrorZ_ok(o_conv);
16940         return tag_ptr(ret_conv, true);
16941 }
16942
16943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16944         void* e_ptr = untag_ptr(e);
16945         CHECK_ACCESS(e_ptr);
16946         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16947         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16948         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
16949         *ret_conv = CResult_BlindedHopDecodeErrorZ_err(e_conv);
16950         return tag_ptr(ret_conv, true);
16951 }
16952
16953 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16954         LDKCResult_BlindedHopDecodeErrorZ* o_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(o);
16955         jboolean ret_conv = CResult_BlindedHopDecodeErrorZ_is_ok(o_conv);
16956         return ret_conv;
16957 }
16958
16959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16960         if (!ptr_is_owned(_res)) return;
16961         void* _res_ptr = untag_ptr(_res);
16962         CHECK_ACCESS(_res_ptr);
16963         LDKCResult_BlindedHopDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopDecodeErrorZ*)(_res_ptr);
16964         FREE(untag_ptr(_res));
16965         CResult_BlindedHopDecodeErrorZ_free(_res_conv);
16966 }
16967
16968 static inline uint64_t CResult_BlindedHopDecodeErrorZ_clone_ptr(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR arg) {
16969         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
16970         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(arg);
16971         return tag_ptr(ret_conv, true);
16972 }
16973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16974         LDKCResult_BlindedHopDecodeErrorZ* arg_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(arg);
16975         int64_t ret_conv = CResult_BlindedHopDecodeErrorZ_clone_ptr(arg_conv);
16976         return ret_conv;
16977 }
16978
16979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16980         LDKCResult_BlindedHopDecodeErrorZ* orig_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(orig);
16981         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
16982         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(orig_conv);
16983         return tag_ptr(ret_conv, true);
16984 }
16985
16986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16987         void* o_ptr = untag_ptr(o);
16988         CHECK_ACCESS(o_ptr);
16989         LDKWriteableScore o_conv = *(LDKWriteableScore*)(o_ptr);
16990         if (o_conv.free == LDKWriteableScore_JCalls_free) {
16991                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16992                 LDKWriteableScore_JCalls_cloned(&o_conv);
16993         }
16994         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
16995         *ret_copy = COption_WriteableScoreZ_some(o_conv);
16996         int64_t ret_ref = tag_ptr(ret_copy, true);
16997         return ret_ref;
16998 }
16999
17000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1none(JNIEnv *env, jclass clz) {
17001         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
17002         *ret_copy = COption_WriteableScoreZ_none();
17003         int64_t ret_ref = tag_ptr(ret_copy, true);
17004         return ret_ref;
17005 }
17006
17007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17008         if (!ptr_is_owned(_res)) return;
17009         void* _res_ptr = untag_ptr(_res);
17010         CHECK_ACCESS(_res_ptr);
17011         LDKCOption_WriteableScoreZ _res_conv = *(LDKCOption_WriteableScoreZ*)(_res_ptr);
17012         FREE(untag_ptr(_res));
17013         COption_WriteableScoreZ_free(_res_conv);
17014 }
17015
17016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
17017         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17018         *ret_conv = CResult_NoneErrorZ_ok();
17019         return tag_ptr(ret_conv, true);
17020 }
17021
17022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17023         LDKIOError e_conv = LDKIOError_from_java(env, e);
17024         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17025         *ret_conv = CResult_NoneErrorZ_err(e_conv);
17026         return tag_ptr(ret_conv, true);
17027 }
17028
17029 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17030         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)untag_ptr(o);
17031         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
17032         return ret_conv;
17033 }
17034
17035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17036         if (!ptr_is_owned(_res)) return;
17037         void* _res_ptr = untag_ptr(_res);
17038         CHECK_ACCESS(_res_ptr);
17039         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
17040         FREE(untag_ptr(_res));
17041         CResult_NoneErrorZ_free(_res_conv);
17042 }
17043
17044 static inline uint64_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
17045         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17046         *ret_conv = CResult_NoneErrorZ_clone(arg);
17047         return tag_ptr(ret_conv, true);
17048 }
17049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17050         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)untag_ptr(arg);
17051         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
17052         return ret_conv;
17053 }
17054
17055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17056         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)untag_ptr(orig);
17057         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17058         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
17059         return tag_ptr(ret_conv, true);
17060 }
17061
17062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17063         LDKCVec_ChannelDetailsZ _res_constr;
17064         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17065         if (_res_constr.datalen > 0)
17066                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
17067         else
17068                 _res_constr.data = NULL;
17069         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17070         for (size_t q = 0; q < _res_constr.datalen; q++) {
17071                 int64_t _res_conv_16 = _res_vals[q];
17072                 LDKChannelDetails _res_conv_16_conv;
17073                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
17074                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
17075                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17076                 _res_constr.data[q] = _res_conv_16_conv;
17077         }
17078         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17079         CVec_ChannelDetailsZ_free(_res_constr);
17080 }
17081
17082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17083         LDKRoute o_conv;
17084         o_conv.inner = untag_ptr(o);
17085         o_conv.is_owned = ptr_is_owned(o);
17086         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17087         o_conv = Route_clone(&o_conv);
17088         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17089         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
17090         return tag_ptr(ret_conv, true);
17091 }
17092
17093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17094         LDKLightningError e_conv;
17095         e_conv.inner = untag_ptr(e);
17096         e_conv.is_owned = ptr_is_owned(e);
17097         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17098         e_conv = LightningError_clone(&e_conv);
17099         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17100         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
17101         return tag_ptr(ret_conv, true);
17102 }
17103
17104 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17105         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(o);
17106         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
17107         return ret_conv;
17108 }
17109
17110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17111         if (!ptr_is_owned(_res)) return;
17112         void* _res_ptr = untag_ptr(_res);
17113         CHECK_ACCESS(_res_ptr);
17114         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
17115         FREE(untag_ptr(_res));
17116         CResult_RouteLightningErrorZ_free(_res_conv);
17117 }
17118
17119 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
17120         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17121         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
17122         return tag_ptr(ret_conv, true);
17123 }
17124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17125         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(arg);
17126         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
17127         return ret_conv;
17128 }
17129
17130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17131         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(orig);
17132         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17133         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
17134         return tag_ptr(ret_conv, true);
17135 }
17136
17137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17138         LDKCVec_RouteHopZ _res_constr;
17139         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17140         if (_res_constr.datalen > 0)
17141                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17142         else
17143                 _res_constr.data = NULL;
17144         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17145         for (size_t k = 0; k < _res_constr.datalen; k++) {
17146                 int64_t _res_conv_10 = _res_vals[k];
17147                 LDKRouteHop _res_conv_10_conv;
17148                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
17149                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
17150                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
17151                 _res_constr.data[k] = _res_conv_10_conv;
17152         }
17153         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17154         CVec_RouteHopZ_free(_res_constr);
17155 }
17156
17157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
17158         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
17159         *ret_copy = COption_u64Z_some(o);
17160         int64_t ret_ref = tag_ptr(ret_copy, true);
17161         return ret_ref;
17162 }
17163
17164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
17165         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
17166         *ret_copy = COption_u64Z_none();
17167         int64_t ret_ref = tag_ptr(ret_copy, true);
17168         return ret_ref;
17169 }
17170
17171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17172         if (!ptr_is_owned(_res)) return;
17173         void* _res_ptr = untag_ptr(_res);
17174         CHECK_ACCESS(_res_ptr);
17175         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
17176         FREE(untag_ptr(_res));
17177         COption_u64Z_free(_res_conv);
17178 }
17179
17180 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
17181         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
17182         *ret_copy = COption_u64Z_clone(arg);
17183         int64_t ret_ref = tag_ptr(ret_copy, true);
17184         return ret_ref;
17185 }
17186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17187         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)untag_ptr(arg);
17188         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
17189         return ret_conv;
17190 }
17191
17192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17193         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)untag_ptr(orig);
17194         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
17195         *ret_copy = COption_u64Z_clone(orig_conv);
17196         int64_t ret_ref = tag_ptr(ret_copy, true);
17197         return ret_ref;
17198 }
17199
17200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17201         LDKInFlightHtlcs o_conv;
17202         o_conv.inner = untag_ptr(o);
17203         o_conv.is_owned = ptr_is_owned(o);
17204         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17205         o_conv = InFlightHtlcs_clone(&o_conv);
17206         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17207         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_ok(o_conv);
17208         return tag_ptr(ret_conv, true);
17209 }
17210
17211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17212         void* e_ptr = untag_ptr(e);
17213         CHECK_ACCESS(e_ptr);
17214         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17215         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17216         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17217         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_err(e_conv);
17218         return tag_ptr(ret_conv, true);
17219 }
17220
17221 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17222         LDKCResult_InFlightHtlcsDecodeErrorZ* o_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(o);
17223         jboolean ret_conv = CResult_InFlightHtlcsDecodeErrorZ_is_ok(o_conv);
17224         return ret_conv;
17225 }
17226
17227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17228         if (!ptr_is_owned(_res)) return;
17229         void* _res_ptr = untag_ptr(_res);
17230         CHECK_ACCESS(_res_ptr);
17231         LDKCResult_InFlightHtlcsDecodeErrorZ _res_conv = *(LDKCResult_InFlightHtlcsDecodeErrorZ*)(_res_ptr);
17232         FREE(untag_ptr(_res));
17233         CResult_InFlightHtlcsDecodeErrorZ_free(_res_conv);
17234 }
17235
17236 static inline uint64_t CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR arg) {
17237         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17238         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone(arg);
17239         return tag_ptr(ret_conv, true);
17240 }
17241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17242         LDKCResult_InFlightHtlcsDecodeErrorZ* arg_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(arg);
17243         int64_t ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(arg_conv);
17244         return ret_conv;
17245 }
17246
17247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17248         LDKCResult_InFlightHtlcsDecodeErrorZ* orig_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(orig);
17249         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17250         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone(orig_conv);
17251         return tag_ptr(ret_conv, true);
17252 }
17253
17254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17255         LDKRouteHop o_conv;
17256         o_conv.inner = untag_ptr(o);
17257         o_conv.is_owned = ptr_is_owned(o);
17258         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17259         o_conv = RouteHop_clone(&o_conv);
17260         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17261         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
17262         return tag_ptr(ret_conv, true);
17263 }
17264
17265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17266         void* e_ptr = untag_ptr(e);
17267         CHECK_ACCESS(e_ptr);
17268         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17269         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17270         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17271         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
17272         return tag_ptr(ret_conv, true);
17273 }
17274
17275 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17276         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(o);
17277         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
17278         return ret_conv;
17279 }
17280
17281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17282         if (!ptr_is_owned(_res)) return;
17283         void* _res_ptr = untag_ptr(_res);
17284         CHECK_ACCESS(_res_ptr);
17285         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
17286         FREE(untag_ptr(_res));
17287         CResult_RouteHopDecodeErrorZ_free(_res_conv);
17288 }
17289
17290 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
17291         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17292         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
17293         return tag_ptr(ret_conv, true);
17294 }
17295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17296         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(arg);
17297         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
17298         return ret_conv;
17299 }
17300
17301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17302         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(orig);
17303         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17304         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
17305         return tag_ptr(ret_conv, true);
17306 }
17307
17308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17309         LDKCVec_CVec_RouteHopZZ _res_constr;
17310         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17311         if (_res_constr.datalen > 0)
17312                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
17313         else
17314                 _res_constr.data = NULL;
17315         for (size_t m = 0; m < _res_constr.datalen; m++) {
17316                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
17317                 LDKCVec_RouteHopZ _res_conv_12_constr;
17318                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
17319                 if (_res_conv_12_constr.datalen > 0)
17320                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17321                 else
17322                         _res_conv_12_constr.data = NULL;
17323                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
17324                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
17325                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
17326                         LDKRouteHop _res_conv_12_conv_10_conv;
17327                         _res_conv_12_conv_10_conv.inner = untag_ptr(_res_conv_12_conv_10);
17328                         _res_conv_12_conv_10_conv.is_owned = ptr_is_owned(_res_conv_12_conv_10);
17329                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
17330                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
17331                 }
17332                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
17333                 _res_constr.data[m] = _res_conv_12_constr;
17334         }
17335         CVec_CVec_RouteHopZZ_free(_res_constr);
17336 }
17337
17338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17339         LDKRoute o_conv;
17340         o_conv.inner = untag_ptr(o);
17341         o_conv.is_owned = ptr_is_owned(o);
17342         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17343         o_conv = Route_clone(&o_conv);
17344         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17345         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
17346         return tag_ptr(ret_conv, true);
17347 }
17348
17349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17350         void* e_ptr = untag_ptr(e);
17351         CHECK_ACCESS(e_ptr);
17352         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17353         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17354         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17355         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
17356         return tag_ptr(ret_conv, true);
17357 }
17358
17359 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17360         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(o);
17361         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
17362         return ret_conv;
17363 }
17364
17365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17366         if (!ptr_is_owned(_res)) return;
17367         void* _res_ptr = untag_ptr(_res);
17368         CHECK_ACCESS(_res_ptr);
17369         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
17370         FREE(untag_ptr(_res));
17371         CResult_RouteDecodeErrorZ_free(_res_conv);
17372 }
17373
17374 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
17375         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17376         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
17377         return tag_ptr(ret_conv, true);
17378 }
17379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17380         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(arg);
17381         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
17382         return ret_conv;
17383 }
17384
17385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17386         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(orig);
17387         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17388         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
17389         return tag_ptr(ret_conv, true);
17390 }
17391
17392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17393         LDKRouteParameters o_conv;
17394         o_conv.inner = untag_ptr(o);
17395         o_conv.is_owned = ptr_is_owned(o);
17396         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17397         o_conv = RouteParameters_clone(&o_conv);
17398         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17399         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
17400         return tag_ptr(ret_conv, true);
17401 }
17402
17403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17404         void* e_ptr = untag_ptr(e);
17405         CHECK_ACCESS(e_ptr);
17406         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17407         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17408         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17409         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
17410         return tag_ptr(ret_conv, true);
17411 }
17412
17413 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17414         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(o);
17415         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
17416         return ret_conv;
17417 }
17418
17419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17420         if (!ptr_is_owned(_res)) return;
17421         void* _res_ptr = untag_ptr(_res);
17422         CHECK_ACCESS(_res_ptr);
17423         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
17424         FREE(untag_ptr(_res));
17425         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
17426 }
17427
17428 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
17429         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17430         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
17431         return tag_ptr(ret_conv, true);
17432 }
17433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17434         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(arg);
17435         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
17436         return ret_conv;
17437 }
17438
17439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17440         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(orig);
17441         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17442         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
17443         return tag_ptr(ret_conv, true);
17444 }
17445
17446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17447         LDKCVec_RouteHintZ _res_constr;
17448         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17449         if (_res_constr.datalen > 0)
17450                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
17451         else
17452                 _res_constr.data = NULL;
17453         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17454         for (size_t l = 0; l < _res_constr.datalen; l++) {
17455                 int64_t _res_conv_11 = _res_vals[l];
17456                 LDKRouteHint _res_conv_11_conv;
17457                 _res_conv_11_conv.inner = untag_ptr(_res_conv_11);
17458                 _res_conv_11_conv.is_owned = ptr_is_owned(_res_conv_11);
17459                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
17460                 _res_constr.data[l] = _res_conv_11_conv;
17461         }
17462         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17463         CVec_RouteHintZ_free(_res_constr);
17464 }
17465
17466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17467         LDKCVec_u64Z _res_constr;
17468         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17469         if (_res_constr.datalen > 0)
17470                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17471         else
17472                 _res_constr.data = NULL;
17473         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17474         for (size_t g = 0; g < _res_constr.datalen; g++) {
17475                 int64_t _res_conv_6 = _res_vals[g];
17476                 _res_constr.data[g] = _res_conv_6;
17477         }
17478         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17479         CVec_u64Z_free(_res_constr);
17480 }
17481
17482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17483         LDKPaymentParameters o_conv;
17484         o_conv.inner = untag_ptr(o);
17485         o_conv.is_owned = ptr_is_owned(o);
17486         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17487         o_conv = PaymentParameters_clone(&o_conv);
17488         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17489         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
17490         return tag_ptr(ret_conv, true);
17491 }
17492
17493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17494         void* e_ptr = untag_ptr(e);
17495         CHECK_ACCESS(e_ptr);
17496         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17497         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17498         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17499         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
17500         return tag_ptr(ret_conv, true);
17501 }
17502
17503 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17504         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(o);
17505         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
17506         return ret_conv;
17507 }
17508
17509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17510         if (!ptr_is_owned(_res)) return;
17511         void* _res_ptr = untag_ptr(_res);
17512         CHECK_ACCESS(_res_ptr);
17513         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
17514         FREE(untag_ptr(_res));
17515         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
17516 }
17517
17518 static inline uint64_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
17519         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17520         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
17521         return tag_ptr(ret_conv, true);
17522 }
17523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17524         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(arg);
17525         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
17526         return ret_conv;
17527 }
17528
17529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17530         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(orig);
17531         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17532         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
17533         return tag_ptr(ret_conv, true);
17534 }
17535
17536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17537         LDKCVec_RouteHintHopZ _res_constr;
17538         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17539         if (_res_constr.datalen > 0)
17540                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
17541         else
17542                 _res_constr.data = NULL;
17543         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17544         for (size_t o = 0; o < _res_constr.datalen; o++) {
17545                 int64_t _res_conv_14 = _res_vals[o];
17546                 LDKRouteHintHop _res_conv_14_conv;
17547                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
17548                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
17549                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
17550                 _res_constr.data[o] = _res_conv_14_conv;
17551         }
17552         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17553         CVec_RouteHintHopZ_free(_res_constr);
17554 }
17555
17556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17557         LDKRouteHint o_conv;
17558         o_conv.inner = untag_ptr(o);
17559         o_conv.is_owned = ptr_is_owned(o);
17560         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17561         o_conv = RouteHint_clone(&o_conv);
17562         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17563         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
17564         return tag_ptr(ret_conv, true);
17565 }
17566
17567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17568         void* e_ptr = untag_ptr(e);
17569         CHECK_ACCESS(e_ptr);
17570         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17571         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17572         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17573         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
17574         return tag_ptr(ret_conv, true);
17575 }
17576
17577 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17578         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(o);
17579         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
17580         return ret_conv;
17581 }
17582
17583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17584         if (!ptr_is_owned(_res)) return;
17585         void* _res_ptr = untag_ptr(_res);
17586         CHECK_ACCESS(_res_ptr);
17587         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
17588         FREE(untag_ptr(_res));
17589         CResult_RouteHintDecodeErrorZ_free(_res_conv);
17590 }
17591
17592 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
17593         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17594         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
17595         return tag_ptr(ret_conv, true);
17596 }
17597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17598         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(arg);
17599         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
17600         return ret_conv;
17601 }
17602
17603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17604         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(orig);
17605         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17606         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
17607         return tag_ptr(ret_conv, true);
17608 }
17609
17610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17611         LDKRouteHintHop o_conv;
17612         o_conv.inner = untag_ptr(o);
17613         o_conv.is_owned = ptr_is_owned(o);
17614         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17615         o_conv = RouteHintHop_clone(&o_conv);
17616         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17617         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
17618         return tag_ptr(ret_conv, true);
17619 }
17620
17621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17622         void* e_ptr = untag_ptr(e);
17623         CHECK_ACCESS(e_ptr);
17624         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17625         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17626         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17627         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
17628         return tag_ptr(ret_conv, true);
17629 }
17630
17631 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17632         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(o);
17633         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
17634         return ret_conv;
17635 }
17636
17637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17638         if (!ptr_is_owned(_res)) return;
17639         void* _res_ptr = untag_ptr(_res);
17640         CHECK_ACCESS(_res_ptr);
17641         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
17642         FREE(untag_ptr(_res));
17643         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
17644 }
17645
17646 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
17647         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17648         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
17649         return tag_ptr(ret_conv, true);
17650 }
17651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17652         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(arg);
17653         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
17654         return ret_conv;
17655 }
17656
17657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17658         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(orig);
17659         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17660         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
17661         return tag_ptr(ret_conv, true);
17662 }
17663
17664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17665         void* o_ptr = untag_ptr(o);
17666         CHECK_ACCESS(o_ptr);
17667         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
17668         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(o));
17669         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17670         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
17671         return tag_ptr(ret_conv, true);
17672 }
17673
17674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17675         void* e_ptr = untag_ptr(e);
17676         CHECK_ACCESS(e_ptr);
17677         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17678         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17679         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17680         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
17681         return tag_ptr(ret_conv, true);
17682 }
17683
17684 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17685         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(o);
17686         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
17687         return ret_conv;
17688 }
17689
17690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17691         if (!ptr_is_owned(_res)) return;
17692         void* _res_ptr = untag_ptr(_res);
17693         CHECK_ACCESS(_res_ptr);
17694         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
17695         FREE(untag_ptr(_res));
17696         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
17697 }
17698
17699 static inline uint64_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
17700         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17701         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
17702         return tag_ptr(ret_conv, true);
17703 }
17704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17705         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(arg);
17706         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
17707         return ret_conv;
17708 }
17709
17710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17711         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(orig);
17712         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17713         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
17714         return tag_ptr(ret_conv, true);
17715 }
17716
17717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17718         void* o_ptr = untag_ptr(o);
17719         CHECK_ACCESS(o_ptr);
17720         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
17721         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)untag_ptr(o));
17722         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17723         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
17724         int64_t ret_ref = tag_ptr(ret_copy, true);
17725         return ret_ref;
17726 }
17727
17728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
17729         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17730         *ret_copy = COption_NetworkUpdateZ_none();
17731         int64_t ret_ref = tag_ptr(ret_copy, true);
17732         return ret_ref;
17733 }
17734
17735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17736         if (!ptr_is_owned(_res)) return;
17737         void* _res_ptr = untag_ptr(_res);
17738         CHECK_ACCESS(_res_ptr);
17739         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
17740         FREE(untag_ptr(_res));
17741         COption_NetworkUpdateZ_free(_res_conv);
17742 }
17743
17744 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
17745         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17746         *ret_copy = COption_NetworkUpdateZ_clone(arg);
17747         int64_t ret_ref = tag_ptr(ret_copy, true);
17748         return ret_ref;
17749 }
17750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17751         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(arg);
17752         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
17753         return ret_conv;
17754 }
17755
17756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17757         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(orig);
17758         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17759         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
17760         int64_t ret_ref = tag_ptr(ret_copy, true);
17761         return ret_ref;
17762 }
17763
17764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PathFailureZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17765         void* o_ptr = untag_ptr(o);
17766         CHECK_ACCESS(o_ptr);
17767         LDKPathFailure o_conv = *(LDKPathFailure*)(o_ptr);
17768         o_conv = PathFailure_clone((LDKPathFailure*)untag_ptr(o));
17769         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
17770         *ret_copy = COption_PathFailureZ_some(o_conv);
17771         int64_t ret_ref = tag_ptr(ret_copy, true);
17772         return ret_ref;
17773 }
17774
17775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PathFailureZ_1none(JNIEnv *env, jclass clz) {
17776         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
17777         *ret_copy = COption_PathFailureZ_none();
17778         int64_t ret_ref = tag_ptr(ret_copy, true);
17779         return ret_ref;
17780 }
17781
17782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1PathFailureZ_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         LDKCOption_PathFailureZ _res_conv = *(LDKCOption_PathFailureZ*)(_res_ptr);
17787         FREE(untag_ptr(_res));
17788         COption_PathFailureZ_free(_res_conv);
17789 }
17790
17791 static inline uint64_t COption_PathFailureZ_clone_ptr(LDKCOption_PathFailureZ *NONNULL_PTR arg) {
17792         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
17793         *ret_copy = COption_PathFailureZ_clone(arg);
17794         int64_t ret_ref = tag_ptr(ret_copy, true);
17795         return ret_ref;
17796 }
17797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PathFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17798         LDKCOption_PathFailureZ* arg_conv = (LDKCOption_PathFailureZ*)untag_ptr(arg);
17799         int64_t ret_conv = COption_PathFailureZ_clone_ptr(arg_conv);
17800         return ret_conv;
17801 }
17802
17803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PathFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17804         LDKCOption_PathFailureZ* orig_conv = (LDKCOption_PathFailureZ*)untag_ptr(orig);
17805         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
17806         *ret_copy = COption_PathFailureZ_clone(orig_conv);
17807         int64_t ret_ref = tag_ptr(ret_copy, true);
17808         return ret_ref;
17809 }
17810
17811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17812         void* o_ptr = untag_ptr(o);
17813         CHECK_ACCESS(o_ptr);
17814         LDKCOption_PathFailureZ o_conv = *(LDKCOption_PathFailureZ*)(o_ptr);
17815         o_conv = COption_PathFailureZ_clone((LDKCOption_PathFailureZ*)untag_ptr(o));
17816         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
17817         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_ok(o_conv);
17818         return tag_ptr(ret_conv, true);
17819 }
17820
17821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17822         void* e_ptr = untag_ptr(e);
17823         CHECK_ACCESS(e_ptr);
17824         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17825         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17826         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
17827         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_err(e_conv);
17828         return tag_ptr(ret_conv, true);
17829 }
17830
17831 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17832         LDKCResult_COption_PathFailureZDecodeErrorZ* o_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(o);
17833         jboolean ret_conv = CResult_COption_PathFailureZDecodeErrorZ_is_ok(o_conv);
17834         return ret_conv;
17835 }
17836
17837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17838         if (!ptr_is_owned(_res)) return;
17839         void* _res_ptr = untag_ptr(_res);
17840         CHECK_ACCESS(_res_ptr);
17841         LDKCResult_COption_PathFailureZDecodeErrorZ _res_conv = *(LDKCResult_COption_PathFailureZDecodeErrorZ*)(_res_ptr);
17842         FREE(untag_ptr(_res));
17843         CResult_COption_PathFailureZDecodeErrorZ_free(_res_conv);
17844 }
17845
17846 static inline uint64_t CResult_COption_PathFailureZDecodeErrorZ_clone_ptr(LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR arg) {
17847         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
17848         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_clone(arg);
17849         return tag_ptr(ret_conv, true);
17850 }
17851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17852         LDKCResult_COption_PathFailureZDecodeErrorZ* arg_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(arg);
17853         int64_t ret_conv = CResult_COption_PathFailureZDecodeErrorZ_clone_ptr(arg_conv);
17854         return ret_conv;
17855 }
17856
17857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17858         LDKCResult_COption_PathFailureZDecodeErrorZ* orig_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(orig);
17859         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
17860         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_clone(orig_conv);
17861         return tag_ptr(ret_conv, true);
17862 }
17863
17864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17865         void* o_ptr = untag_ptr(o);
17866         CHECK_ACCESS(o_ptr);
17867         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
17868         o_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(o));
17869         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17870         *ret_copy = COption_ClosureReasonZ_some(o_conv);
17871         int64_t ret_ref = tag_ptr(ret_copy, true);
17872         return ret_ref;
17873 }
17874
17875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
17876         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17877         *ret_copy = COption_ClosureReasonZ_none();
17878         int64_t ret_ref = tag_ptr(ret_copy, true);
17879         return ret_ref;
17880 }
17881
17882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17883         if (!ptr_is_owned(_res)) return;
17884         void* _res_ptr = untag_ptr(_res);
17885         CHECK_ACCESS(_res_ptr);
17886         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
17887         FREE(untag_ptr(_res));
17888         COption_ClosureReasonZ_free(_res_conv);
17889 }
17890
17891 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
17892         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17893         *ret_copy = COption_ClosureReasonZ_clone(arg);
17894         int64_t ret_ref = tag_ptr(ret_copy, true);
17895         return ret_ref;
17896 }
17897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17898         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(arg);
17899         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
17900         return ret_conv;
17901 }
17902
17903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17904         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(orig);
17905         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17906         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
17907         int64_t ret_ref = tag_ptr(ret_copy, true);
17908         return ret_ref;
17909 }
17910
17911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17912         void* o_ptr = untag_ptr(o);
17913         CHECK_ACCESS(o_ptr);
17914         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
17915         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)untag_ptr(o));
17916         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17917         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
17918         return tag_ptr(ret_conv, true);
17919 }
17920
17921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17922         void* e_ptr = untag_ptr(e);
17923         CHECK_ACCESS(e_ptr);
17924         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17925         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17926         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17927         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
17928         return tag_ptr(ret_conv, true);
17929 }
17930
17931 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17932         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(o);
17933         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
17934         return ret_conv;
17935 }
17936
17937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17938         if (!ptr_is_owned(_res)) return;
17939         void* _res_ptr = untag_ptr(_res);
17940         CHECK_ACCESS(_res_ptr);
17941         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
17942         FREE(untag_ptr(_res));
17943         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
17944 }
17945
17946 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
17947         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17948         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
17949         return tag_ptr(ret_conv, true);
17950 }
17951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17952         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(arg);
17953         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
17954         return ret_conv;
17955 }
17956
17957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17958         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(orig);
17959         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17960         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
17961         return tag_ptr(ret_conv, true);
17962 }
17963
17964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17965         void* o_ptr = untag_ptr(o);
17966         CHECK_ACCESS(o_ptr);
17967         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
17968         o_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(o));
17969         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17970         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
17971         int64_t ret_ref = tag_ptr(ret_copy, true);
17972         return ret_ref;
17973 }
17974
17975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1none(JNIEnv *env, jclass clz) {
17976         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17977         *ret_copy = COption_HTLCDestinationZ_none();
17978         int64_t ret_ref = tag_ptr(ret_copy, true);
17979         return ret_ref;
17980 }
17981
17982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17983         if (!ptr_is_owned(_res)) return;
17984         void* _res_ptr = untag_ptr(_res);
17985         CHECK_ACCESS(_res_ptr);
17986         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
17987         FREE(untag_ptr(_res));
17988         COption_HTLCDestinationZ_free(_res_conv);
17989 }
17990
17991 static inline uint64_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
17992         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17993         *ret_copy = COption_HTLCDestinationZ_clone(arg);
17994         int64_t ret_ref = tag_ptr(ret_copy, true);
17995         return ret_ref;
17996 }
17997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17998         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(arg);
17999         int64_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
18000         return ret_conv;
18001 }
18002
18003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18004         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(orig);
18005         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
18006         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
18007         int64_t ret_ref = tag_ptr(ret_copy, true);
18008         return ret_ref;
18009 }
18010
18011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18012         void* o_ptr = untag_ptr(o);
18013         CHECK_ACCESS(o_ptr);
18014         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
18015         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)untag_ptr(o));
18016         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
18017         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
18018         return tag_ptr(ret_conv, true);
18019 }
18020
18021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18022         void* e_ptr = untag_ptr(e);
18023         CHECK_ACCESS(e_ptr);
18024         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18025         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18026         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
18027         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
18028         return tag_ptr(ret_conv, true);
18029 }
18030
18031 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18032         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(o);
18033         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
18034         return ret_conv;
18035 }
18036
18037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18038         if (!ptr_is_owned(_res)) return;
18039         void* _res_ptr = untag_ptr(_res);
18040         CHECK_ACCESS(_res_ptr);
18041         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
18042         FREE(untag_ptr(_res));
18043         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
18044 }
18045
18046 static inline uint64_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
18047         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
18048         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
18049         return tag_ptr(ret_conv, true);
18050 }
18051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18052         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(arg);
18053         int64_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
18054         return ret_conv;
18055 }
18056
18057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18058         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(orig);
18059         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
18060         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
18061         return tag_ptr(ret_conv, true);
18062 }
18063
18064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1some(JNIEnv *env, jclass clz, int8_tArray o) {
18065         LDKU128 o_ref;
18066         CHECK((*env)->GetArrayLength(env, o) == 16);
18067         (*env)->GetByteArrayRegion(env, o, 0, 16, o_ref.le_bytes);
18068         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
18069         *ret_copy = COption_u128Z_some(o_ref);
18070         int64_t ret_ref = tag_ptr(ret_copy, true);
18071         return ret_ref;
18072 }
18073
18074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1none(JNIEnv *env, jclass clz) {
18075         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
18076         *ret_copy = COption_u128Z_none();
18077         int64_t ret_ref = tag_ptr(ret_copy, true);
18078         return ret_ref;
18079 }
18080
18081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
18082         if (!ptr_is_owned(_res)) return;
18083         void* _res_ptr = untag_ptr(_res);
18084         CHECK_ACCESS(_res_ptr);
18085         LDKCOption_u128Z _res_conv = *(LDKCOption_u128Z*)(_res_ptr);
18086         FREE(untag_ptr(_res));
18087         COption_u128Z_free(_res_conv);
18088 }
18089
18090 static inline uint64_t COption_u128Z_clone_ptr(LDKCOption_u128Z *NONNULL_PTR arg) {
18091         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
18092         *ret_copy = COption_u128Z_clone(arg);
18093         int64_t ret_ref = tag_ptr(ret_copy, true);
18094         return ret_ref;
18095 }
18096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18097         LDKCOption_u128Z* arg_conv = (LDKCOption_u128Z*)untag_ptr(arg);
18098         int64_t ret_conv = COption_u128Z_clone_ptr(arg_conv);
18099         return ret_conv;
18100 }
18101
18102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18103         LDKCOption_u128Z* orig_conv = (LDKCOption_u128Z*)untag_ptr(orig);
18104         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
18105         *ret_copy = COption_u128Z_clone(orig_conv);
18106         int64_t ret_ref = tag_ptr(ret_copy, true);
18107         return ret_ref;
18108 }
18109
18110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18111         LDKCVec_SpendableOutputDescriptorZ _res_constr;
18112         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18113         if (_res_constr.datalen > 0)
18114                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
18115         else
18116                 _res_constr.data = NULL;
18117         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18118         for (size_t b = 0; b < _res_constr.datalen; b++) {
18119                 int64_t _res_conv_27 = _res_vals[b];
18120                 void* _res_conv_27_ptr = untag_ptr(_res_conv_27);
18121                 CHECK_ACCESS(_res_conv_27_ptr);
18122                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
18123                 FREE(untag_ptr(_res_conv_27));
18124                 _res_constr.data[b] = _res_conv_27_conv;
18125         }
18126         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18127         CVec_SpendableOutputDescriptorZ_free(_res_constr);
18128 }
18129
18130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18131         void* o_ptr = untag_ptr(o);
18132         CHECK_ACCESS(o_ptr);
18133         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
18134         o_conv = Event_clone((LDKEvent*)untag_ptr(o));
18135         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
18136         *ret_copy = COption_EventZ_some(o_conv);
18137         int64_t ret_ref = tag_ptr(ret_copy, true);
18138         return ret_ref;
18139 }
18140
18141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
18142         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
18143         *ret_copy = COption_EventZ_none();
18144         int64_t ret_ref = tag_ptr(ret_copy, true);
18145         return ret_ref;
18146 }
18147
18148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18149         if (!ptr_is_owned(_res)) return;
18150         void* _res_ptr = untag_ptr(_res);
18151         CHECK_ACCESS(_res_ptr);
18152         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
18153         FREE(untag_ptr(_res));
18154         COption_EventZ_free(_res_conv);
18155 }
18156
18157 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
18158         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
18159         *ret_copy = COption_EventZ_clone(arg);
18160         int64_t ret_ref = tag_ptr(ret_copy, true);
18161         return ret_ref;
18162 }
18163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18164         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)untag_ptr(arg);
18165         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
18166         return ret_conv;
18167 }
18168
18169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18170         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)untag_ptr(orig);
18171         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
18172         *ret_copy = COption_EventZ_clone(orig_conv);
18173         int64_t ret_ref = tag_ptr(ret_copy, true);
18174         return ret_ref;
18175 }
18176
18177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18178         void* o_ptr = untag_ptr(o);
18179         CHECK_ACCESS(o_ptr);
18180         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
18181         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)untag_ptr(o));
18182         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
18183         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
18184         return tag_ptr(ret_conv, true);
18185 }
18186
18187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18188         void* e_ptr = untag_ptr(e);
18189         CHECK_ACCESS(e_ptr);
18190         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18191         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18192         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
18193         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
18194         return tag_ptr(ret_conv, true);
18195 }
18196
18197 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18198         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(o);
18199         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
18200         return ret_conv;
18201 }
18202
18203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18204         if (!ptr_is_owned(_res)) return;
18205         void* _res_ptr = untag_ptr(_res);
18206         CHECK_ACCESS(_res_ptr);
18207         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
18208         FREE(untag_ptr(_res));
18209         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
18210 }
18211
18212 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
18213         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
18214         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
18215         return tag_ptr(ret_conv, true);
18216 }
18217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18218         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(arg);
18219         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
18220         return ret_conv;
18221 }
18222
18223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18224         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(orig);
18225         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
18226         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
18227         return tag_ptr(ret_conv, true);
18228 }
18229
18230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18231         LDKCVec_MessageSendEventZ _res_constr;
18232         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18233         if (_res_constr.datalen > 0)
18234                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
18235         else
18236                 _res_constr.data = NULL;
18237         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18238         for (size_t s = 0; s < _res_constr.datalen; s++) {
18239                 int64_t _res_conv_18 = _res_vals[s];
18240                 void* _res_conv_18_ptr = untag_ptr(_res_conv_18);
18241                 CHECK_ACCESS(_res_conv_18_ptr);
18242                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
18243                 FREE(untag_ptr(_res_conv_18));
18244                 _res_constr.data[s] = _res_conv_18_conv;
18245         }
18246         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18247         CVec_MessageSendEventZ_free(_res_constr);
18248 }
18249
18250 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
18251         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18252         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
18253         return tag_ptr(ret_conv, true);
18254 }
18255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18256         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(arg);
18257         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
18258         return ret_conv;
18259 }
18260
18261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18262         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(orig);
18263         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18264         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
18265         return tag_ptr(ret_conv, true);
18266 }
18267
18268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
18269         LDKTransaction b_ref;
18270         b_ref.datalen = (*env)->GetArrayLength(env, b);
18271         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
18272         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
18273         b_ref.data_is_owned = true;
18274         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18275         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
18276         return tag_ptr(ret_conv, true);
18277 }
18278
18279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18280         if (!ptr_is_owned(_res)) return;
18281         void* _res_ptr = untag_ptr(_res);
18282         CHECK_ACCESS(_res_ptr);
18283         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
18284         FREE(untag_ptr(_res));
18285         C2Tuple_usizeTransactionZ_free(_res_conv);
18286 }
18287
18288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18289         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
18290         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18291         if (_res_constr.datalen > 0)
18292                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
18293         else
18294                 _res_constr.data = NULL;
18295         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18296         for (size_t c = 0; c < _res_constr.datalen; c++) {
18297                 int64_t _res_conv_28 = _res_vals[c];
18298                 void* _res_conv_28_ptr = untag_ptr(_res_conv_28);
18299                 CHECK_ACCESS(_res_conv_28_ptr);
18300                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
18301                 FREE(untag_ptr(_res_conv_28));
18302                 _res_constr.data[c] = _res_conv_28_conv;
18303         }
18304         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18305         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
18306 }
18307
18308 static inline uint64_t C2Tuple_TxidBlockHashZ_clone_ptr(LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR arg) {
18309         LDKC2Tuple_TxidBlockHashZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
18310         *ret_conv = C2Tuple_TxidBlockHashZ_clone(arg);
18311         return tag_ptr(ret_conv, true);
18312 }
18313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18314         LDKC2Tuple_TxidBlockHashZ* arg_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(arg);
18315         int64_t ret_conv = C2Tuple_TxidBlockHashZ_clone_ptr(arg_conv);
18316         return ret_conv;
18317 }
18318
18319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18320         LDKC2Tuple_TxidBlockHashZ* orig_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(orig);
18321         LDKC2Tuple_TxidBlockHashZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
18322         *ret_conv = C2Tuple_TxidBlockHashZ_clone(orig_conv);
18323         return tag_ptr(ret_conv, true);
18324 }
18325
18326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
18327         LDKThirtyTwoBytes a_ref;
18328         CHECK((*env)->GetArrayLength(env, a) == 32);
18329         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18330         LDKThirtyTwoBytes b_ref;
18331         CHECK((*env)->GetArrayLength(env, b) == 32);
18332         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
18333         LDKC2Tuple_TxidBlockHashZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
18334         *ret_conv = C2Tuple_TxidBlockHashZ_new(a_ref, b_ref);
18335         return tag_ptr(ret_conv, true);
18336 }
18337
18338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18339         if (!ptr_is_owned(_res)) return;
18340         void* _res_ptr = untag_ptr(_res);
18341         CHECK_ACCESS(_res_ptr);
18342         LDKC2Tuple_TxidBlockHashZ _res_conv = *(LDKC2Tuple_TxidBlockHashZ*)(_res_ptr);
18343         FREE(untag_ptr(_res));
18344         C2Tuple_TxidBlockHashZ_free(_res_conv);
18345 }
18346
18347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidBlockHashZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18348         LDKCVec_C2Tuple_TxidBlockHashZZ _res_constr;
18349         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18350         if (_res_constr.datalen > 0)
18351                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKCVec_C2Tuple_TxidBlockHashZZ Elements");
18352         else
18353                 _res_constr.data = NULL;
18354         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18355         for (size_t z = 0; z < _res_constr.datalen; z++) {
18356                 int64_t _res_conv_25 = _res_vals[z];
18357                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
18358                 CHECK_ACCESS(_res_conv_25_ptr);
18359                 LDKC2Tuple_TxidBlockHashZ _res_conv_25_conv = *(LDKC2Tuple_TxidBlockHashZ*)(_res_conv_25_ptr);
18360                 FREE(untag_ptr(_res_conv_25));
18361                 _res_constr.data[z] = _res_conv_25_conv;
18362         }
18363         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18364         CVec_C2Tuple_TxidBlockHashZZ_free(_res_constr);
18365 }
18366
18367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18368         LDKCVec_MonitorEventZ _res_constr;
18369         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18370         if (_res_constr.datalen > 0)
18371                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
18372         else
18373                 _res_constr.data = NULL;
18374         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18375         for (size_t o = 0; o < _res_constr.datalen; o++) {
18376                 int64_t _res_conv_14 = _res_vals[o];
18377                 void* _res_conv_14_ptr = untag_ptr(_res_conv_14);
18378                 CHECK_ACCESS(_res_conv_14_ptr);
18379                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
18380                 FREE(untag_ptr(_res_conv_14));
18381                 _res_constr.data[o] = _res_conv_14_conv;
18382         }
18383         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18384         CVec_MonitorEventZ_free(_res_constr);
18385 }
18386
18387 static inline uint64_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
18388         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18389         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
18390         return tag_ptr(ret_conv, true);
18391 }
18392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18393         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(arg);
18394         int64_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
18395         return ret_conv;
18396 }
18397
18398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18399         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(orig);
18400         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18401         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
18402         return tag_ptr(ret_conv, true);
18403 }
18404
18405 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) {
18406         LDKOutPoint a_conv;
18407         a_conv.inner = untag_ptr(a);
18408         a_conv.is_owned = ptr_is_owned(a);
18409         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18410         a_conv = OutPoint_clone(&a_conv);
18411         LDKCVec_MonitorEventZ b_constr;
18412         b_constr.datalen = (*env)->GetArrayLength(env, b);
18413         if (b_constr.datalen > 0)
18414                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
18415         else
18416                 b_constr.data = NULL;
18417         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
18418         for (size_t o = 0; o < b_constr.datalen; o++) {
18419                 int64_t b_conv_14 = b_vals[o];
18420                 void* b_conv_14_ptr = untag_ptr(b_conv_14);
18421                 CHECK_ACCESS(b_conv_14_ptr);
18422                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
18423                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(b_conv_14));
18424                 b_constr.data[o] = b_conv_14_conv;
18425         }
18426         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
18427         LDKPublicKey c_ref;
18428         CHECK((*env)->GetArrayLength(env, c) == 33);
18429         (*env)->GetByteArrayRegion(env, c, 0, 33, c_ref.compressed_form);
18430         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18431         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
18432         return tag_ptr(ret_conv, true);
18433 }
18434
18435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18436         if (!ptr_is_owned(_res)) return;
18437         void* _res_ptr = untag_ptr(_res);
18438         CHECK_ACCESS(_res_ptr);
18439         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
18440         FREE(untag_ptr(_res));
18441         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
18442 }
18443
18444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18445         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
18446         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18447         if (_res_constr.datalen > 0)
18448                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
18449         else
18450                 _res_constr.data = NULL;
18451         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18452         for (size_t x = 0; x < _res_constr.datalen; x++) {
18453                 int64_t _res_conv_49 = _res_vals[x];
18454                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
18455                 CHECK_ACCESS(_res_conv_49_ptr);
18456                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
18457                 FREE(untag_ptr(_res_conv_49));
18458                 _res_constr.data[x] = _res_conv_49_conv;
18459         }
18460         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18461         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
18462 }
18463
18464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18465         LDKFixedPenaltyScorer o_conv;
18466         o_conv.inner = untag_ptr(o);
18467         o_conv.is_owned = ptr_is_owned(o);
18468         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18469         o_conv = FixedPenaltyScorer_clone(&o_conv);
18470         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18471         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
18472         return tag_ptr(ret_conv, true);
18473 }
18474
18475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18476         void* e_ptr = untag_ptr(e);
18477         CHECK_ACCESS(e_ptr);
18478         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18479         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18480         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18481         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
18482         return tag_ptr(ret_conv, true);
18483 }
18484
18485 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18486         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(o);
18487         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
18488         return ret_conv;
18489 }
18490
18491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18492         if (!ptr_is_owned(_res)) return;
18493         void* _res_ptr = untag_ptr(_res);
18494         CHECK_ACCESS(_res_ptr);
18495         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
18496         FREE(untag_ptr(_res));
18497         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
18498 }
18499
18500 static inline uint64_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
18501         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18502         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
18503         return tag_ptr(ret_conv, true);
18504 }
18505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18506         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(arg);
18507         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
18508         return ret_conv;
18509 }
18510
18511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18512         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(orig);
18513         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18514         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
18515         return tag_ptr(ret_conv, true);
18516 }
18517
18518 static inline uint64_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
18519         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18520         *ret_conv = C2Tuple_u64u64Z_clone(arg);
18521         return tag_ptr(ret_conv, true);
18522 }
18523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18524         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(arg);
18525         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
18526         return ret_conv;
18527 }
18528
18529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18530         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(orig);
18531         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18532         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
18533         return tag_ptr(ret_conv, true);
18534 }
18535
18536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
18537         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18538         *ret_conv = C2Tuple_u64u64Z_new(a, b);
18539         return tag_ptr(ret_conv, true);
18540 }
18541
18542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
18543         if (!ptr_is_owned(_res)) return;
18544         void* _res_ptr = untag_ptr(_res);
18545         CHECK_ACCESS(_res_ptr);
18546         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
18547         FREE(untag_ptr(_res));
18548         C2Tuple_u64u64Z_free(_res_conv);
18549 }
18550
18551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18552         void* o_ptr = untag_ptr(o);
18553         CHECK_ACCESS(o_ptr);
18554         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
18555         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)untag_ptr(o));
18556         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18557         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
18558         int64_t ret_ref = tag_ptr(ret_copy, true);
18559         return ret_ref;
18560 }
18561
18562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1none(JNIEnv *env, jclass clz) {
18563         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18564         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
18565         int64_t ret_ref = tag_ptr(ret_copy, true);
18566         return ret_ref;
18567 }
18568
18569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18570         if (!ptr_is_owned(_res)) return;
18571         void* _res_ptr = untag_ptr(_res);
18572         CHECK_ACCESS(_res_ptr);
18573         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
18574         FREE(untag_ptr(_res));
18575         COption_C2Tuple_u64u64ZZ_free(_res_conv);
18576 }
18577
18578 static inline uint64_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
18579         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18580         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
18581         int64_t ret_ref = tag_ptr(ret_copy, true);
18582         return ret_ref;
18583 }
18584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18585         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(arg);
18586         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
18587         return ret_conv;
18588 }
18589
18590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18591         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(orig);
18592         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18593         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
18594         int64_t ret_ref = tag_ptr(ret_copy, true);
18595         return ret_ref;
18596 }
18597
18598 static inline uint64_t C2Tuple_Z_clone_ptr(LDKC2Tuple_Z *NONNULL_PTR arg) {
18599         LDKC2Tuple_Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_Z), "LDKC2Tuple_Z");
18600         *ret_conv = C2Tuple_Z_clone(arg);
18601         return tag_ptr(ret_conv, true);
18602 }
18603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18604         LDKC2Tuple_Z* arg_conv = (LDKC2Tuple_Z*)untag_ptr(arg);
18605         int64_t ret_conv = C2Tuple_Z_clone_ptr(arg_conv);
18606         return ret_conv;
18607 }
18608
18609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18610         LDKC2Tuple_Z* orig_conv = (LDKC2Tuple_Z*)untag_ptr(orig);
18611         LDKC2Tuple_Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_Z), "LDKC2Tuple_Z");
18612         *ret_conv = C2Tuple_Z_clone(orig_conv);
18613         return tag_ptr(ret_conv, true);
18614 }
18615
18616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1new(JNIEnv *env, jclass clz, int16_tArray a, int16_tArray b) {
18617         LDKEightU16s a_ref;
18618         CHECK((*env)->GetArrayLength(env, a) == 8);
18619         (*env)->GetShortArrayRegion(env, a, 0, 8, a_ref.data);
18620         LDKEightU16s b_ref;
18621         CHECK((*env)->GetArrayLength(env, b) == 8);
18622         (*env)->GetShortArrayRegion(env, b, 0, 8, b_ref.data);
18623         LDKC2Tuple_Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_Z), "LDKC2Tuple_Z");
18624         *ret_conv = C2Tuple_Z_new(a_ref, b_ref);
18625         return tag_ptr(ret_conv, true);
18626 }
18627
18628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
18629         if (!ptr_is_owned(_res)) return;
18630         void* _res_ptr = untag_ptr(_res);
18631         CHECK_ACCESS(_res_ptr);
18632         LDKC2Tuple_Z _res_conv = *(LDKC2Tuple_Z*)(_res_ptr);
18633         FREE(untag_ptr(_res));
18634         C2Tuple_Z_free(_res_conv);
18635 }
18636
18637 static inline uint64_t C2Tuple__u168_u168Z_clone_ptr(LDKC2Tuple__u168_u168Z *NONNULL_PTR arg) {
18638         LDKC2Tuple__u168_u168Z* ret_conv = MALLOC(sizeof(LDKC2Tuple__u168_u168Z), "LDKC2Tuple__u168_u168Z");
18639         *ret_conv = C2Tuple__u168_u168Z_clone(arg);
18640         return tag_ptr(ret_conv, true);
18641 }
18642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18643         LDKC2Tuple__u168_u168Z* arg_conv = (LDKC2Tuple__u168_u168Z*)untag_ptr(arg);
18644         int64_t ret_conv = C2Tuple__u168_u168Z_clone_ptr(arg_conv);
18645         return ret_conv;
18646 }
18647
18648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18649         LDKC2Tuple__u168_u168Z* orig_conv = (LDKC2Tuple__u168_u168Z*)untag_ptr(orig);
18650         LDKC2Tuple__u168_u168Z* ret_conv = MALLOC(sizeof(LDKC2Tuple__u168_u168Z), "LDKC2Tuple__u168_u168Z");
18651         *ret_conv = C2Tuple__u168_u168Z_clone(orig_conv);
18652         return tag_ptr(ret_conv, true);
18653 }
18654
18655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1new(JNIEnv *env, jclass clz, int16_tArray a, int16_tArray b) {
18656         LDKEightU16s a_ref;
18657         CHECK((*env)->GetArrayLength(env, a) == 8);
18658         (*env)->GetShortArrayRegion(env, a, 0, 8, a_ref.data);
18659         LDKEightU16s b_ref;
18660         CHECK((*env)->GetArrayLength(env, b) == 8);
18661         (*env)->GetShortArrayRegion(env, b, 0, 8, b_ref.data);
18662         LDKC2Tuple__u168_u168Z* ret_conv = MALLOC(sizeof(LDKC2Tuple__u168_u168Z), "LDKC2Tuple__u168_u168Z");
18663         *ret_conv = C2Tuple__u168_u168Z_new(a_ref, b_ref);
18664         return tag_ptr(ret_conv, true);
18665 }
18666
18667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
18668         if (!ptr_is_owned(_res)) return;
18669         void* _res_ptr = untag_ptr(_res);
18670         CHECK_ACCESS(_res_ptr);
18671         LDKC2Tuple__u168_u168Z _res_conv = *(LDKC2Tuple__u168_u168Z*)(_res_ptr);
18672         FREE(untag_ptr(_res));
18673         C2Tuple__u168_u168Z_free(_res_conv);
18674 }
18675
18676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1EightU16sEightU16sZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18677         void* o_ptr = untag_ptr(o);
18678         CHECK_ACCESS(o_ptr);
18679         LDKC2Tuple__u168_u168Z o_conv = *(LDKC2Tuple__u168_u168Z*)(o_ptr);
18680         o_conv = C2Tuple__u168_u168Z_clone((LDKC2Tuple__u168_u168Z*)untag_ptr(o));
18681         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
18682         *ret_copy = COption_C2Tuple_EightU16sEightU16sZZ_some(o_conv);
18683         int64_t ret_ref = tag_ptr(ret_copy, true);
18684         return ret_ref;
18685 }
18686
18687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1EightU16sEightU16sZZ_1none(JNIEnv *env, jclass clz) {
18688         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
18689         *ret_copy = COption_C2Tuple_EightU16sEightU16sZZ_none();
18690         int64_t ret_ref = tag_ptr(ret_copy, true);
18691         return ret_ref;
18692 }
18693
18694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1EightU16sEightU16sZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18695         if (!ptr_is_owned(_res)) return;
18696         void* _res_ptr = untag_ptr(_res);
18697         CHECK_ACCESS(_res_ptr);
18698         LDKCOption_C2Tuple_EightU16sEightU16sZZ _res_conv = *(LDKCOption_C2Tuple_EightU16sEightU16sZZ*)(_res_ptr);
18699         FREE(untag_ptr(_res));
18700         COption_C2Tuple_EightU16sEightU16sZZ_free(_res_conv);
18701 }
18702
18703 static inline uint64_t COption_C2Tuple_EightU16sEightU16sZZ_clone_ptr(LDKCOption_C2Tuple_EightU16sEightU16sZZ *NONNULL_PTR arg) {
18704         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
18705         *ret_copy = COption_C2Tuple_EightU16sEightU16sZZ_clone(arg);
18706         int64_t ret_ref = tag_ptr(ret_copy, true);
18707         return ret_ref;
18708 }
18709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1EightU16sEightU16sZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18710         LDKCOption_C2Tuple_EightU16sEightU16sZZ* arg_conv = (LDKCOption_C2Tuple_EightU16sEightU16sZZ*)untag_ptr(arg);
18711         int64_t ret_conv = COption_C2Tuple_EightU16sEightU16sZZ_clone_ptr(arg_conv);
18712         return ret_conv;
18713 }
18714
18715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1EightU16sEightU16sZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18716         LDKCOption_C2Tuple_EightU16sEightU16sZZ* orig_conv = (LDKCOption_C2Tuple_EightU16sEightU16sZZ*)untag_ptr(orig);
18717         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
18718         *ret_copy = COption_C2Tuple_EightU16sEightU16sZZ_clone(orig_conv);
18719         int64_t ret_ref = tag_ptr(ret_copy, true);
18720         return ret_ref;
18721 }
18722
18723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18724         LDKCVec_NodeIdZ _res_constr;
18725         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18726         if (_res_constr.datalen > 0)
18727                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
18728         else
18729                 _res_constr.data = NULL;
18730         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18731         for (size_t i = 0; i < _res_constr.datalen; i++) {
18732                 int64_t _res_conv_8 = _res_vals[i];
18733                 LDKNodeId _res_conv_8_conv;
18734                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
18735                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
18736                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
18737                 _res_constr.data[i] = _res_conv_8_conv;
18738         }
18739         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18740         CVec_NodeIdZ_free(_res_constr);
18741 }
18742
18743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18744         LDKProbabilisticScorer o_conv;
18745         o_conv.inner = untag_ptr(o);
18746         o_conv.is_owned = ptr_is_owned(o);
18747         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18748         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
18749         
18750         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18751         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
18752         return tag_ptr(ret_conv, true);
18753 }
18754
18755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18756         void* e_ptr = untag_ptr(e);
18757         CHECK_ACCESS(e_ptr);
18758         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18759         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18760         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18761         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
18762         return tag_ptr(ret_conv, true);
18763 }
18764
18765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18766         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(o);
18767         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
18768         return ret_conv;
18769 }
18770
18771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18772         if (!ptr_is_owned(_res)) return;
18773         void* _res_ptr = untag_ptr(_res);
18774         CHECK_ACCESS(_res_ptr);
18775         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
18776         FREE(untag_ptr(_res));
18777         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
18778 }
18779
18780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18781         LDKInitFeatures o_conv;
18782         o_conv.inner = untag_ptr(o);
18783         o_conv.is_owned = ptr_is_owned(o);
18784         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18785         o_conv = InitFeatures_clone(&o_conv);
18786         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18787         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
18788         return tag_ptr(ret_conv, true);
18789 }
18790
18791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18792         void* e_ptr = untag_ptr(e);
18793         CHECK_ACCESS(e_ptr);
18794         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18795         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18796         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18797         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
18798         return tag_ptr(ret_conv, true);
18799 }
18800
18801 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18802         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(o);
18803         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
18804         return ret_conv;
18805 }
18806
18807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18808         if (!ptr_is_owned(_res)) return;
18809         void* _res_ptr = untag_ptr(_res);
18810         CHECK_ACCESS(_res_ptr);
18811         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
18812         FREE(untag_ptr(_res));
18813         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
18814 }
18815
18816 static inline uint64_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18817         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18818         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
18819         return tag_ptr(ret_conv, true);
18820 }
18821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18822         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(arg);
18823         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18824         return ret_conv;
18825 }
18826
18827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18828         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(orig);
18829         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18830         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
18831         return tag_ptr(ret_conv, true);
18832 }
18833
18834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18835         LDKChannelFeatures o_conv;
18836         o_conv.inner = untag_ptr(o);
18837         o_conv.is_owned = ptr_is_owned(o);
18838         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18839         o_conv = ChannelFeatures_clone(&o_conv);
18840         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18841         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
18842         return tag_ptr(ret_conv, true);
18843 }
18844
18845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18846         void* e_ptr = untag_ptr(e);
18847         CHECK_ACCESS(e_ptr);
18848         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18849         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18850         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18851         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
18852         return tag_ptr(ret_conv, true);
18853 }
18854
18855 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18856         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(o);
18857         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
18858         return ret_conv;
18859 }
18860
18861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18862         if (!ptr_is_owned(_res)) return;
18863         void* _res_ptr = untag_ptr(_res);
18864         CHECK_ACCESS(_res_ptr);
18865         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
18866         FREE(untag_ptr(_res));
18867         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
18868 }
18869
18870 static inline uint64_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18871         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18872         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
18873         return tag_ptr(ret_conv, true);
18874 }
18875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18876         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(arg);
18877         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18878         return ret_conv;
18879 }
18880
18881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18882         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(orig);
18883         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18884         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
18885         return tag_ptr(ret_conv, true);
18886 }
18887
18888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18889         LDKNodeFeatures o_conv;
18890         o_conv.inner = untag_ptr(o);
18891         o_conv.is_owned = ptr_is_owned(o);
18892         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18893         o_conv = NodeFeatures_clone(&o_conv);
18894         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18895         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
18896         return tag_ptr(ret_conv, true);
18897 }
18898
18899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18900         void* e_ptr = untag_ptr(e);
18901         CHECK_ACCESS(e_ptr);
18902         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18903         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18904         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18905         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
18906         return tag_ptr(ret_conv, true);
18907 }
18908
18909 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18910         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(o);
18911         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
18912         return ret_conv;
18913 }
18914
18915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18916         if (!ptr_is_owned(_res)) return;
18917         void* _res_ptr = untag_ptr(_res);
18918         CHECK_ACCESS(_res_ptr);
18919         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
18920         FREE(untag_ptr(_res));
18921         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
18922 }
18923
18924 static inline uint64_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18925         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18926         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
18927         return tag_ptr(ret_conv, true);
18928 }
18929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18930         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(arg);
18931         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18932         return ret_conv;
18933 }
18934
18935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18936         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(orig);
18937         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18938         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
18939         return tag_ptr(ret_conv, true);
18940 }
18941
18942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18943         LDKInvoiceFeatures o_conv;
18944         o_conv.inner = untag_ptr(o);
18945         o_conv.is_owned = ptr_is_owned(o);
18946         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18947         o_conv = InvoiceFeatures_clone(&o_conv);
18948         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18949         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
18950         return tag_ptr(ret_conv, true);
18951 }
18952
18953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18954         void* e_ptr = untag_ptr(e);
18955         CHECK_ACCESS(e_ptr);
18956         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18957         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18958         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18959         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
18960         return tag_ptr(ret_conv, true);
18961 }
18962
18963 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18964         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(o);
18965         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
18966         return ret_conv;
18967 }
18968
18969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18970         if (!ptr_is_owned(_res)) return;
18971         void* _res_ptr = untag_ptr(_res);
18972         CHECK_ACCESS(_res_ptr);
18973         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
18974         FREE(untag_ptr(_res));
18975         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
18976 }
18977
18978 static inline uint64_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18979         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18980         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
18981         return tag_ptr(ret_conv, true);
18982 }
18983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18984         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(arg);
18985         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18986         return ret_conv;
18987 }
18988
18989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18990         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(orig);
18991         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18992         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
18993         return tag_ptr(ret_conv, true);
18994 }
18995
18996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18997         LDKBlindedHopFeatures o_conv;
18998         o_conv.inner = untag_ptr(o);
18999         o_conv.is_owned = ptr_is_owned(o);
19000         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19001         o_conv = BlindedHopFeatures_clone(&o_conv);
19002         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
19003         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_ok(o_conv);
19004         return tag_ptr(ret_conv, true);
19005 }
19006
19007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19008         void* e_ptr = untag_ptr(e);
19009         CHECK_ACCESS(e_ptr);
19010         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19011         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19012         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
19013         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_err(e_conv);
19014         return tag_ptr(ret_conv, true);
19015 }
19016
19017 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19018         LDKCResult_BlindedHopFeaturesDecodeErrorZ* o_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(o);
19019         jboolean ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(o_conv);
19020         return ret_conv;
19021 }
19022
19023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19024         if (!ptr_is_owned(_res)) return;
19025         void* _res_ptr = untag_ptr(_res);
19026         CHECK_ACCESS(_res_ptr);
19027         LDKCResult_BlindedHopFeaturesDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopFeaturesDecodeErrorZ*)(_res_ptr);
19028         FREE(untag_ptr(_res));
19029         CResult_BlindedHopFeaturesDecodeErrorZ_free(_res_conv);
19030 }
19031
19032 static inline uint64_t CResult_BlindedHopFeaturesDecodeErrorZ_clone_ptr(LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR arg) {
19033         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
19034         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_clone(arg);
19035         return tag_ptr(ret_conv, true);
19036 }
19037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19038         LDKCResult_BlindedHopFeaturesDecodeErrorZ* arg_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(arg);
19039         int64_t ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19040         return ret_conv;
19041 }
19042
19043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19044         LDKCResult_BlindedHopFeaturesDecodeErrorZ* orig_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(orig);
19045         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
19046         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_clone(orig_conv);
19047         return tag_ptr(ret_conv, true);
19048 }
19049
19050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19051         LDKChannelTypeFeatures o_conv;
19052         o_conv.inner = untag_ptr(o);
19053         o_conv.is_owned = ptr_is_owned(o);
19054         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19055         o_conv = ChannelTypeFeatures_clone(&o_conv);
19056         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
19057         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
19058         return tag_ptr(ret_conv, true);
19059 }
19060
19061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19062         void* e_ptr = untag_ptr(e);
19063         CHECK_ACCESS(e_ptr);
19064         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19065         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19066         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
19067         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
19068         return tag_ptr(ret_conv, true);
19069 }
19070
19071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19072         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(o);
19073         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
19074         return ret_conv;
19075 }
19076
19077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19078         if (!ptr_is_owned(_res)) return;
19079         void* _res_ptr = untag_ptr(_res);
19080         CHECK_ACCESS(_res_ptr);
19081         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
19082         FREE(untag_ptr(_res));
19083         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
19084 }
19085
19086 static inline uint64_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
19087         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
19088         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
19089         return tag_ptr(ret_conv, true);
19090 }
19091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19092         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(arg);
19093         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19094         return ret_conv;
19095 }
19096
19097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19098         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(orig);
19099         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
19100         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
19101         return tag_ptr(ret_conv, true);
19102 }
19103
19104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19105         LDKNodeId o_conv;
19106         o_conv.inner = untag_ptr(o);
19107         o_conv.is_owned = ptr_is_owned(o);
19108         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19109         o_conv = NodeId_clone(&o_conv);
19110         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19111         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
19112         return tag_ptr(ret_conv, true);
19113 }
19114
19115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19116         void* e_ptr = untag_ptr(e);
19117         CHECK_ACCESS(e_ptr);
19118         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19119         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19120         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19121         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
19122         return tag_ptr(ret_conv, true);
19123 }
19124
19125 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19126         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(o);
19127         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
19128         return ret_conv;
19129 }
19130
19131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19132         if (!ptr_is_owned(_res)) return;
19133         void* _res_ptr = untag_ptr(_res);
19134         CHECK_ACCESS(_res_ptr);
19135         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
19136         FREE(untag_ptr(_res));
19137         CResult_NodeIdDecodeErrorZ_free(_res_conv);
19138 }
19139
19140 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
19141         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19142         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
19143         return tag_ptr(ret_conv, true);
19144 }
19145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19146         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(arg);
19147         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
19148         return ret_conv;
19149 }
19150
19151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19152         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(orig);
19153         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19154         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
19155         return tag_ptr(ret_conv, true);
19156 }
19157
19158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19159         void* o_ptr = untag_ptr(o);
19160         CHECK_ACCESS(o_ptr);
19161         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
19162         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(o));
19163         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19164         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
19165         return tag_ptr(ret_conv, true);
19166 }
19167
19168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19169         void* e_ptr = untag_ptr(e);
19170         CHECK_ACCESS(e_ptr);
19171         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19172         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19173         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19174         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
19175         return tag_ptr(ret_conv, true);
19176 }
19177
19178 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19179         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(o);
19180         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
19181         return ret_conv;
19182 }
19183
19184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19185         if (!ptr_is_owned(_res)) return;
19186         void* _res_ptr = untag_ptr(_res);
19187         CHECK_ACCESS(_res_ptr);
19188         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
19189         FREE(untag_ptr(_res));
19190         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
19191 }
19192
19193 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
19194         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19195         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
19196         return tag_ptr(ret_conv, true);
19197 }
19198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19199         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(arg);
19200         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
19201         return ret_conv;
19202 }
19203
19204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19205         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(orig);
19206         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19207         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
19208         return tag_ptr(ret_conv, true);
19209 }
19210
19211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1UtxoLookupZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19212         void* o_ptr = untag_ptr(o);
19213         CHECK_ACCESS(o_ptr);
19214         LDKUtxoLookup o_conv = *(LDKUtxoLookup*)(o_ptr);
19215         if (o_conv.free == LDKUtxoLookup_JCalls_free) {
19216                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19217                 LDKUtxoLookup_JCalls_cloned(&o_conv);
19218         }
19219         LDKCOption_UtxoLookupZ *ret_copy = MALLOC(sizeof(LDKCOption_UtxoLookupZ), "LDKCOption_UtxoLookupZ");
19220         *ret_copy = COption_UtxoLookupZ_some(o_conv);
19221         int64_t ret_ref = tag_ptr(ret_copy, true);
19222         return ret_ref;
19223 }
19224
19225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1UtxoLookupZ_1none(JNIEnv *env, jclass clz) {
19226         LDKCOption_UtxoLookupZ *ret_copy = MALLOC(sizeof(LDKCOption_UtxoLookupZ), "LDKCOption_UtxoLookupZ");
19227         *ret_copy = COption_UtxoLookupZ_none();
19228         int64_t ret_ref = tag_ptr(ret_copy, true);
19229         return ret_ref;
19230 }
19231
19232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1UtxoLookupZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19233         if (!ptr_is_owned(_res)) return;
19234         void* _res_ptr = untag_ptr(_res);
19235         CHECK_ACCESS(_res_ptr);
19236         LDKCOption_UtxoLookupZ _res_conv = *(LDKCOption_UtxoLookupZ*)(_res_ptr);
19237         FREE(untag_ptr(_res));
19238         COption_UtxoLookupZ_free(_res_conv);
19239 }
19240
19241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
19242         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19243         *ret_conv = CResult_boolLightningErrorZ_ok(o);
19244         return tag_ptr(ret_conv, true);
19245 }
19246
19247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19248         LDKLightningError e_conv;
19249         e_conv.inner = untag_ptr(e);
19250         e_conv.is_owned = ptr_is_owned(e);
19251         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19252         e_conv = LightningError_clone(&e_conv);
19253         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19254         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
19255         return tag_ptr(ret_conv, true);
19256 }
19257
19258 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19259         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(o);
19260         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
19261         return ret_conv;
19262 }
19263
19264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19265         if (!ptr_is_owned(_res)) return;
19266         void* _res_ptr = untag_ptr(_res);
19267         CHECK_ACCESS(_res_ptr);
19268         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
19269         FREE(untag_ptr(_res));
19270         CResult_boolLightningErrorZ_free(_res_conv);
19271 }
19272
19273 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
19274         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19275         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
19276         return tag_ptr(ret_conv, true);
19277 }
19278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19279         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(arg);
19280         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
19281         return ret_conv;
19282 }
19283
19284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19285         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(orig);
19286         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19287         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
19288         return tag_ptr(ret_conv, true);
19289 }
19290
19291 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
19292         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19293         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
19294         return tag_ptr(ret_conv, true);
19295 }
19296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19297         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(arg);
19298         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
19299         return ret_conv;
19300 }
19301
19302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19303         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(orig);
19304         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19305         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
19306         return tag_ptr(ret_conv, true);
19307 }
19308
19309 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) {
19310         LDKChannelAnnouncement a_conv;
19311         a_conv.inner = untag_ptr(a);
19312         a_conv.is_owned = ptr_is_owned(a);
19313         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19314         a_conv = ChannelAnnouncement_clone(&a_conv);
19315         LDKChannelUpdate b_conv;
19316         b_conv.inner = untag_ptr(b);
19317         b_conv.is_owned = ptr_is_owned(b);
19318         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19319         b_conv = ChannelUpdate_clone(&b_conv);
19320         LDKChannelUpdate c_conv;
19321         c_conv.inner = untag_ptr(c);
19322         c_conv.is_owned = ptr_is_owned(c);
19323         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
19324         c_conv = ChannelUpdate_clone(&c_conv);
19325         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19326         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
19327         return tag_ptr(ret_conv, true);
19328 }
19329
19330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19331         if (!ptr_is_owned(_res)) return;
19332         void* _res_ptr = untag_ptr(_res);
19333         CHECK_ACCESS(_res_ptr);
19334         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
19335         FREE(untag_ptr(_res));
19336         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
19337 }
19338
19339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19340         void* o_ptr = untag_ptr(o);
19341         CHECK_ACCESS(o_ptr);
19342         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(o_ptr);
19343         o_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(o));
19344         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19345         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(o_conv);
19346         int64_t ret_ref = tag_ptr(ret_copy, true);
19347         return ret_ref;
19348 }
19349
19350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1none(JNIEnv *env, jclass clz) {
19351         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19352         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none();
19353         int64_t ret_ref = tag_ptr(ret_copy, true);
19354         return ret_ref;
19355 }
19356
19357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19358         if (!ptr_is_owned(_res)) return;
19359         void* _res_ptr = untag_ptr(_res);
19360         CHECK_ACCESS(_res_ptr);
19361         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(_res_ptr);
19362         FREE(untag_ptr(_res));
19363         COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_conv);
19364 }
19365
19366 static inline uint64_t COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *NONNULL_PTR arg) {
19367         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19368         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(arg);
19369         int64_t ret_ref = tag_ptr(ret_copy, true);
19370         return ret_ref;
19371 }
19372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19373         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* arg_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(arg);
19374         int64_t ret_conv = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(arg_conv);
19375         return ret_conv;
19376 }
19377
19378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19379         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* orig_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(orig);
19380         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19381         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig_conv);
19382         int64_t ret_ref = tag_ptr(ret_copy, true);
19383         return ret_ref;
19384 }
19385
19386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
19387         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19388         *ret_conv = CResult_NoneLightningErrorZ_ok();
19389         return tag_ptr(ret_conv, true);
19390 }
19391
19392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19393         LDKLightningError e_conv;
19394         e_conv.inner = untag_ptr(e);
19395         e_conv.is_owned = ptr_is_owned(e);
19396         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19397         e_conv = LightningError_clone(&e_conv);
19398         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19399         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
19400         return tag_ptr(ret_conv, true);
19401 }
19402
19403 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19404         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(o);
19405         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
19406         return ret_conv;
19407 }
19408
19409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19410         if (!ptr_is_owned(_res)) return;
19411         void* _res_ptr = untag_ptr(_res);
19412         CHECK_ACCESS(_res_ptr);
19413         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
19414         FREE(untag_ptr(_res));
19415         CResult_NoneLightningErrorZ_free(_res_conv);
19416 }
19417
19418 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
19419         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19420         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
19421         return tag_ptr(ret_conv, true);
19422 }
19423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19424         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(arg);
19425         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
19426         return ret_conv;
19427 }
19428
19429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19430         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(orig);
19431         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19432         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
19433         return tag_ptr(ret_conv, true);
19434 }
19435
19436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19437         LDKChannelUpdateInfo o_conv;
19438         o_conv.inner = untag_ptr(o);
19439         o_conv.is_owned = ptr_is_owned(o);
19440         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19441         o_conv = ChannelUpdateInfo_clone(&o_conv);
19442         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19443         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
19444         return tag_ptr(ret_conv, true);
19445 }
19446
19447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19448         void* e_ptr = untag_ptr(e);
19449         CHECK_ACCESS(e_ptr);
19450         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19451         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19452         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19453         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
19454         return tag_ptr(ret_conv, true);
19455 }
19456
19457 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19458         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(o);
19459         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
19460         return ret_conv;
19461 }
19462
19463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19464         if (!ptr_is_owned(_res)) return;
19465         void* _res_ptr = untag_ptr(_res);
19466         CHECK_ACCESS(_res_ptr);
19467         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
19468         FREE(untag_ptr(_res));
19469         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
19470 }
19471
19472 static inline uint64_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
19473         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19474         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
19475         return tag_ptr(ret_conv, true);
19476 }
19477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19478         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(arg);
19479         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
19480         return ret_conv;
19481 }
19482
19483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19484         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(orig);
19485         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19486         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
19487         return tag_ptr(ret_conv, true);
19488 }
19489
19490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19491         LDKChannelInfo o_conv;
19492         o_conv.inner = untag_ptr(o);
19493         o_conv.is_owned = ptr_is_owned(o);
19494         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19495         o_conv = ChannelInfo_clone(&o_conv);
19496         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19497         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
19498         return tag_ptr(ret_conv, true);
19499 }
19500
19501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19502         void* e_ptr = untag_ptr(e);
19503         CHECK_ACCESS(e_ptr);
19504         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19505         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19506         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19507         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
19508         return tag_ptr(ret_conv, true);
19509 }
19510
19511 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19512         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(o);
19513         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
19514         return ret_conv;
19515 }
19516
19517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19518         if (!ptr_is_owned(_res)) return;
19519         void* _res_ptr = untag_ptr(_res);
19520         CHECK_ACCESS(_res_ptr);
19521         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
19522         FREE(untag_ptr(_res));
19523         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
19524 }
19525
19526 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
19527         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19528         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
19529         return tag_ptr(ret_conv, true);
19530 }
19531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19532         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(arg);
19533         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
19534         return ret_conv;
19535 }
19536
19537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19538         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(orig);
19539         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19540         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
19541         return tag_ptr(ret_conv, true);
19542 }
19543
19544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19545         LDKRoutingFees o_conv;
19546         o_conv.inner = untag_ptr(o);
19547         o_conv.is_owned = ptr_is_owned(o);
19548         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19549         o_conv = RoutingFees_clone(&o_conv);
19550         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19551         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
19552         return tag_ptr(ret_conv, true);
19553 }
19554
19555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19556         void* e_ptr = untag_ptr(e);
19557         CHECK_ACCESS(e_ptr);
19558         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19559         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19560         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19561         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
19562         return tag_ptr(ret_conv, true);
19563 }
19564
19565 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19566         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(o);
19567         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
19568         return ret_conv;
19569 }
19570
19571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19572         if (!ptr_is_owned(_res)) return;
19573         void* _res_ptr = untag_ptr(_res);
19574         CHECK_ACCESS(_res_ptr);
19575         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
19576         FREE(untag_ptr(_res));
19577         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
19578 }
19579
19580 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
19581         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19582         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
19583         return tag_ptr(ret_conv, true);
19584 }
19585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19586         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(arg);
19587         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
19588         return ret_conv;
19589 }
19590
19591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19592         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(orig);
19593         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19594         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
19595         return tag_ptr(ret_conv, true);
19596 }
19597
19598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19599         LDKCVec_NetAddressZ _res_constr;
19600         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19601         if (_res_constr.datalen > 0)
19602                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19603         else
19604                 _res_constr.data = NULL;
19605         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19606         for (size_t m = 0; m < _res_constr.datalen; m++) {
19607                 int64_t _res_conv_12 = _res_vals[m];
19608                 void* _res_conv_12_ptr = untag_ptr(_res_conv_12);
19609                 CHECK_ACCESS(_res_conv_12_ptr);
19610                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
19611                 FREE(untag_ptr(_res_conv_12));
19612                 _res_constr.data[m] = _res_conv_12_conv;
19613         }
19614         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19615         CVec_NetAddressZ_free(_res_constr);
19616 }
19617
19618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19619         LDKNodeAnnouncementInfo o_conv;
19620         o_conv.inner = untag_ptr(o);
19621         o_conv.is_owned = ptr_is_owned(o);
19622         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19623         o_conv = NodeAnnouncementInfo_clone(&o_conv);
19624         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19625         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
19626         return tag_ptr(ret_conv, true);
19627 }
19628
19629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19630         void* e_ptr = untag_ptr(e);
19631         CHECK_ACCESS(e_ptr);
19632         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19633         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19634         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19635         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
19636         return tag_ptr(ret_conv, true);
19637 }
19638
19639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19640         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(o);
19641         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
19642         return ret_conv;
19643 }
19644
19645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19646         if (!ptr_is_owned(_res)) return;
19647         void* _res_ptr = untag_ptr(_res);
19648         CHECK_ACCESS(_res_ptr);
19649         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
19650         FREE(untag_ptr(_res));
19651         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
19652 }
19653
19654 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
19655         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19656         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
19657         return tag_ptr(ret_conv, true);
19658 }
19659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19660         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(arg);
19661         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
19662         return ret_conv;
19663 }
19664
19665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19666         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(orig);
19667         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19668         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
19669         return tag_ptr(ret_conv, true);
19670 }
19671
19672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19673         LDKNodeAlias o_conv;
19674         o_conv.inner = untag_ptr(o);
19675         o_conv.is_owned = ptr_is_owned(o);
19676         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19677         o_conv = NodeAlias_clone(&o_conv);
19678         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
19679         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
19680         return tag_ptr(ret_conv, true);
19681 }
19682
19683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19684         void* e_ptr = untag_ptr(e);
19685         CHECK_ACCESS(e_ptr);
19686         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19687         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19688         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
19689         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
19690         return tag_ptr(ret_conv, true);
19691 }
19692
19693 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19694         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(o);
19695         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
19696         return ret_conv;
19697 }
19698
19699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19700         if (!ptr_is_owned(_res)) return;
19701         void* _res_ptr = untag_ptr(_res);
19702         CHECK_ACCESS(_res_ptr);
19703         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
19704         FREE(untag_ptr(_res));
19705         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
19706 }
19707
19708 static inline uint64_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
19709         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
19710         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
19711         return tag_ptr(ret_conv, true);
19712 }
19713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19714         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(arg);
19715         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
19716         return ret_conv;
19717 }
19718
19719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19720         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(orig);
19721         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
19722         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
19723         return tag_ptr(ret_conv, true);
19724 }
19725
19726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19727         LDKNodeInfo o_conv;
19728         o_conv.inner = untag_ptr(o);
19729         o_conv.is_owned = ptr_is_owned(o);
19730         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19731         o_conv = NodeInfo_clone(&o_conv);
19732         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19733         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
19734         return tag_ptr(ret_conv, true);
19735 }
19736
19737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19738         void* e_ptr = untag_ptr(e);
19739         CHECK_ACCESS(e_ptr);
19740         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19741         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19742         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19743         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
19744         return tag_ptr(ret_conv, true);
19745 }
19746
19747 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19748         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(o);
19749         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
19750         return ret_conv;
19751 }
19752
19753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19754         if (!ptr_is_owned(_res)) return;
19755         void* _res_ptr = untag_ptr(_res);
19756         CHECK_ACCESS(_res_ptr);
19757         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
19758         FREE(untag_ptr(_res));
19759         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
19760 }
19761
19762 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
19763         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19764         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
19765         return tag_ptr(ret_conv, true);
19766 }
19767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19768         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(arg);
19769         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
19770         return ret_conv;
19771 }
19772
19773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19774         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(orig);
19775         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19776         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
19777         return tag_ptr(ret_conv, true);
19778 }
19779
19780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19781         LDKNetworkGraph o_conv;
19782         o_conv.inner = untag_ptr(o);
19783         o_conv.is_owned = ptr_is_owned(o);
19784         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19785         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
19786         
19787         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
19788         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
19789         return tag_ptr(ret_conv, true);
19790 }
19791
19792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19793         void* e_ptr = untag_ptr(e);
19794         CHECK_ACCESS(e_ptr);
19795         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19796         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19797         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
19798         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
19799         return tag_ptr(ret_conv, true);
19800 }
19801
19802 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19803         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(o);
19804         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
19805         return ret_conv;
19806 }
19807
19808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19809         if (!ptr_is_owned(_res)) return;
19810         void* _res_ptr = untag_ptr(_res);
19811         CHECK_ACCESS(_res_ptr);
19812         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
19813         FREE(untag_ptr(_res));
19814         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
19815 }
19816
19817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
19818         LDKCVec_NetAddressZ o_constr;
19819         o_constr.datalen = (*env)->GetArrayLength(env, o);
19820         if (o_constr.datalen > 0)
19821                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19822         else
19823                 o_constr.data = NULL;
19824         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
19825         for (size_t m = 0; m < o_constr.datalen; m++) {
19826                 int64_t o_conv_12 = o_vals[m];
19827                 void* o_conv_12_ptr = untag_ptr(o_conv_12);
19828                 CHECK_ACCESS(o_conv_12_ptr);
19829                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
19830                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o_conv_12));
19831                 o_constr.data[m] = o_conv_12_conv;
19832         }
19833         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
19834         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19835         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
19836         int64_t ret_ref = tag_ptr(ret_copy, true);
19837         return ret_ref;
19838 }
19839
19840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
19841         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19842         *ret_copy = COption_CVec_NetAddressZZ_none();
19843         int64_t ret_ref = tag_ptr(ret_copy, true);
19844         return ret_ref;
19845 }
19846
19847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19848         if (!ptr_is_owned(_res)) return;
19849         void* _res_ptr = untag_ptr(_res);
19850         CHECK_ACCESS(_res_ptr);
19851         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
19852         FREE(untag_ptr(_res));
19853         COption_CVec_NetAddressZZ_free(_res_conv);
19854 }
19855
19856 static inline uint64_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
19857         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19858         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
19859         int64_t ret_ref = tag_ptr(ret_copy, true);
19860         return ret_ref;
19861 }
19862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19863         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(arg);
19864         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
19865         return ret_conv;
19866 }
19867
19868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19869         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(orig);
19870         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19871         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
19872         int64_t ret_ref = tag_ptr(ret_copy, true);
19873         return ret_ref;
19874 }
19875
19876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19877         LDKDelayedPaymentOutputDescriptor o_conv;
19878         o_conv.inner = untag_ptr(o);
19879         o_conv.is_owned = ptr_is_owned(o);
19880         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19881         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
19882         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19883         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
19884         return tag_ptr(ret_conv, true);
19885 }
19886
19887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19888         void* e_ptr = untag_ptr(e);
19889         CHECK_ACCESS(e_ptr);
19890         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19891         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19892         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19893         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
19894         return tag_ptr(ret_conv, true);
19895 }
19896
19897 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19898         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
19899         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
19900         return ret_conv;
19901 }
19902
19903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19904         if (!ptr_is_owned(_res)) return;
19905         void* _res_ptr = untag_ptr(_res);
19906         CHECK_ACCESS(_res_ptr);
19907         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
19908         FREE(untag_ptr(_res));
19909         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
19910 }
19911
19912 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
19913         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19914         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
19915         return tag_ptr(ret_conv, true);
19916 }
19917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19918         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
19919         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
19920         return ret_conv;
19921 }
19922
19923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19924         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
19925         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19926         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
19927         return tag_ptr(ret_conv, true);
19928 }
19929
19930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19931         LDKStaticPaymentOutputDescriptor o_conv;
19932         o_conv.inner = untag_ptr(o);
19933         o_conv.is_owned = ptr_is_owned(o);
19934         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19935         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
19936         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19937         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
19938         return tag_ptr(ret_conv, true);
19939 }
19940
19941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19942         void* e_ptr = untag_ptr(e);
19943         CHECK_ACCESS(e_ptr);
19944         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19945         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19946         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19947         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
19948         return tag_ptr(ret_conv, true);
19949 }
19950
19951 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19952         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
19953         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
19954         return ret_conv;
19955 }
19956
19957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19958         if (!ptr_is_owned(_res)) return;
19959         void* _res_ptr = untag_ptr(_res);
19960         CHECK_ACCESS(_res_ptr);
19961         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
19962         FREE(untag_ptr(_res));
19963         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
19964 }
19965
19966 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
19967         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19968         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
19969         return tag_ptr(ret_conv, true);
19970 }
19971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19972         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
19973         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
19974         return ret_conv;
19975 }
19976
19977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19978         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
19979         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19980         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
19981         return tag_ptr(ret_conv, true);
19982 }
19983
19984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19985         void* o_ptr = untag_ptr(o);
19986         CHECK_ACCESS(o_ptr);
19987         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
19988         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(o));
19989         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19990         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
19991         return tag_ptr(ret_conv, true);
19992 }
19993
19994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19995         void* e_ptr = untag_ptr(e);
19996         CHECK_ACCESS(e_ptr);
19997         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19998         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19999         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20000         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
20001         return tag_ptr(ret_conv, true);
20002 }
20003
20004 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20005         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(o);
20006         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
20007         return ret_conv;
20008 }
20009
20010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20011         if (!ptr_is_owned(_res)) return;
20012         void* _res_ptr = untag_ptr(_res);
20013         CHECK_ACCESS(_res_ptr);
20014         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
20015         FREE(untag_ptr(_res));
20016         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
20017 }
20018
20019 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
20020         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20021         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
20022         return tag_ptr(ret_conv, true);
20023 }
20024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20025         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
20026         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
20027         return ret_conv;
20028 }
20029
20030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20031         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
20032         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20033         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
20034         return tag_ptr(ret_conv, true);
20035 }
20036
20037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20038         LDKCVec_PaymentPreimageZ _res_constr;
20039         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20040         if (_res_constr.datalen > 0)
20041                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
20042         else
20043                 _res_constr.data = NULL;
20044         for (size_t i = 0; i < _res_constr.datalen; i++) {
20045                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
20046                 LDKThirtyTwoBytes _res_conv_8_ref;
20047                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
20048                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
20049                 _res_constr.data[i] = _res_conv_8_ref;
20050         }
20051         CVec_PaymentPreimageZ_free(_res_constr);
20052 }
20053
20054 static inline uint64_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
20055         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
20056         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
20057         return tag_ptr(ret_conv, true);
20058 }
20059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20060         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(arg);
20061         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
20062         return ret_conv;
20063 }
20064
20065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20066         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(orig);
20067         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
20068         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
20069         return tag_ptr(ret_conv, true);
20070 }
20071
20072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
20073         LDKSignature a_ref;
20074         CHECK((*env)->GetArrayLength(env, a) == 64);
20075         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
20076         LDKCVec_SignatureZ b_constr;
20077         b_constr.datalen = (*env)->GetArrayLength(env, b);
20078         if (b_constr.datalen > 0)
20079                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
20080         else
20081                 b_constr.data = NULL;
20082         for (size_t i = 0; i < b_constr.datalen; i++) {
20083                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
20084                 LDKSignature b_conv_8_ref;
20085                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
20086                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
20087                 b_constr.data[i] = b_conv_8_ref;
20088         }
20089         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
20090         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
20091         return tag_ptr(ret_conv, true);
20092 }
20093
20094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20095         if (!ptr_is_owned(_res)) return;
20096         void* _res_ptr = untag_ptr(_res);
20097         CHECK_ACCESS(_res_ptr);
20098         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
20099         FREE(untag_ptr(_res));
20100         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
20101 }
20102
20103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20104         void* o_ptr = untag_ptr(o);
20105         CHECK_ACCESS(o_ptr);
20106         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
20107         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(o));
20108         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
20109         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
20110         return tag_ptr(ret_conv, true);
20111 }
20112
20113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
20114         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
20115         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
20116         return tag_ptr(ret_conv, true);
20117 }
20118
20119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20120         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(o);
20121         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
20122         return ret_conv;
20123 }
20124
20125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20126         if (!ptr_is_owned(_res)) return;
20127         void* _res_ptr = untag_ptr(_res);
20128         CHECK_ACCESS(_res_ptr);
20129         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
20130         FREE(untag_ptr(_res));
20131         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
20132 }
20133
20134 static inline uint64_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
20135         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
20136         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
20137         return tag_ptr(ret_conv, true);
20138 }
20139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20140         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(arg);
20141         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
20142         return ret_conv;
20143 }
20144
20145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20146         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(orig);
20147         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
20148         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
20149         return tag_ptr(ret_conv, true);
20150 }
20151
20152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20153         LDKSignature o_ref;
20154         CHECK((*env)->GetArrayLength(env, o) == 64);
20155         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
20156         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20157         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
20158         return tag_ptr(ret_conv, true);
20159 }
20160
20161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
20162         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20163         *ret_conv = CResult_SignatureNoneZ_err();
20164         return tag_ptr(ret_conv, true);
20165 }
20166
20167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20168         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(o);
20169         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
20170         return ret_conv;
20171 }
20172
20173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20174         if (!ptr_is_owned(_res)) return;
20175         void* _res_ptr = untag_ptr(_res);
20176         CHECK_ACCESS(_res_ptr);
20177         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
20178         FREE(untag_ptr(_res));
20179         CResult_SignatureNoneZ_free(_res_conv);
20180 }
20181
20182 static inline uint64_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
20183         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20184         *ret_conv = CResult_SignatureNoneZ_clone(arg);
20185         return tag_ptr(ret_conv, true);
20186 }
20187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20188         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(arg);
20189         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
20190         return ret_conv;
20191 }
20192
20193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20194         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(orig);
20195         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20196         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
20197         return tag_ptr(ret_conv, true);
20198 }
20199
20200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20201         LDKPublicKey o_ref;
20202         CHECK((*env)->GetArrayLength(env, o) == 33);
20203         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
20204         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20205         *ret_conv = CResult_PublicKeyNoneZ_ok(o_ref);
20206         return tag_ptr(ret_conv, true);
20207 }
20208
20209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1err(JNIEnv *env, jclass clz) {
20210         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20211         *ret_conv = CResult_PublicKeyNoneZ_err();
20212         return tag_ptr(ret_conv, true);
20213 }
20214
20215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20216         LDKCResult_PublicKeyNoneZ* o_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(o);
20217         jboolean ret_conv = CResult_PublicKeyNoneZ_is_ok(o_conv);
20218         return ret_conv;
20219 }
20220
20221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20222         if (!ptr_is_owned(_res)) return;
20223         void* _res_ptr = untag_ptr(_res);
20224         CHECK_ACCESS(_res_ptr);
20225         LDKCResult_PublicKeyNoneZ _res_conv = *(LDKCResult_PublicKeyNoneZ*)(_res_ptr);
20226         FREE(untag_ptr(_res));
20227         CResult_PublicKeyNoneZ_free(_res_conv);
20228 }
20229
20230 static inline uint64_t CResult_PublicKeyNoneZ_clone_ptr(LDKCResult_PublicKeyNoneZ *NONNULL_PTR arg) {
20231         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20232         *ret_conv = CResult_PublicKeyNoneZ_clone(arg);
20233         return tag_ptr(ret_conv, true);
20234 }
20235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20236         LDKCResult_PublicKeyNoneZ* arg_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(arg);
20237         int64_t ret_conv = CResult_PublicKeyNoneZ_clone_ptr(arg_conv);
20238         return ret_conv;
20239 }
20240
20241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20242         LDKCResult_PublicKeyNoneZ* orig_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(orig);
20243         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20244         *ret_conv = CResult_PublicKeyNoneZ_clone(orig_conv);
20245         return tag_ptr(ret_conv, true);
20246 }
20247
20248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20249         void* o_ptr = untag_ptr(o);
20250         CHECK_ACCESS(o_ptr);
20251         LDKBigEndianScalar o_conv = *(LDKBigEndianScalar*)(o_ptr);
20252         // WARNING: we may need a move here but no clone is available for LDKBigEndianScalar
20253         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
20254         *ret_copy = COption_ScalarZ_some(o_conv);
20255         int64_t ret_ref = tag_ptr(ret_copy, true);
20256         return ret_ref;
20257 }
20258
20259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1none(JNIEnv *env, jclass clz) {
20260         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
20261         *ret_copy = COption_ScalarZ_none();
20262         int64_t ret_ref = tag_ptr(ret_copy, true);
20263         return ret_ref;
20264 }
20265
20266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20267         if (!ptr_is_owned(_res)) return;
20268         void* _res_ptr = untag_ptr(_res);
20269         CHECK_ACCESS(_res_ptr);
20270         LDKCOption_ScalarZ _res_conv = *(LDKCOption_ScalarZ*)(_res_ptr);
20271         FREE(untag_ptr(_res));
20272         COption_ScalarZ_free(_res_conv);
20273 }
20274
20275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20276         LDKThirtyTwoBytes o_ref;
20277         CHECK((*env)->GetArrayLength(env, o) == 32);
20278         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20279         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20280         *ret_conv = CResult_SharedSecretNoneZ_ok(o_ref);
20281         return tag_ptr(ret_conv, true);
20282 }
20283
20284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1err(JNIEnv *env, jclass clz) {
20285         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20286         *ret_conv = CResult_SharedSecretNoneZ_err();
20287         return tag_ptr(ret_conv, true);
20288 }
20289
20290 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20291         LDKCResult_SharedSecretNoneZ* o_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(o);
20292         jboolean ret_conv = CResult_SharedSecretNoneZ_is_ok(o_conv);
20293         return ret_conv;
20294 }
20295
20296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20297         if (!ptr_is_owned(_res)) return;
20298         void* _res_ptr = untag_ptr(_res);
20299         CHECK_ACCESS(_res_ptr);
20300         LDKCResult_SharedSecretNoneZ _res_conv = *(LDKCResult_SharedSecretNoneZ*)(_res_ptr);
20301         FREE(untag_ptr(_res));
20302         CResult_SharedSecretNoneZ_free(_res_conv);
20303 }
20304
20305 static inline uint64_t CResult_SharedSecretNoneZ_clone_ptr(LDKCResult_SharedSecretNoneZ *NONNULL_PTR arg) {
20306         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20307         *ret_conv = CResult_SharedSecretNoneZ_clone(arg);
20308         return tag_ptr(ret_conv, true);
20309 }
20310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20311         LDKCResult_SharedSecretNoneZ* arg_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(arg);
20312         int64_t ret_conv = CResult_SharedSecretNoneZ_clone_ptr(arg_conv);
20313         return ret_conv;
20314 }
20315
20316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20317         LDKCResult_SharedSecretNoneZ* orig_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(orig);
20318         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20319         *ret_conv = CResult_SharedSecretNoneZ_clone(orig_conv);
20320         return tag_ptr(ret_conv, true);
20321 }
20322
20323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1U5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20324         LDKCVec_U5Z _res_constr;
20325         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20326         if (_res_constr.datalen > 0)
20327                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
20328         else
20329                 _res_constr.data = NULL;
20330         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
20331         for (size_t h = 0; h < _res_constr.datalen; h++) {
20332                 int8_t _res_conv_7 = _res_vals[h];
20333                 
20334                 _res_constr.data[h] = (LDKU5){ ._0 = _res_conv_7 };
20335         }
20336         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
20337         CVec_U5Z_free(_res_constr);
20338 }
20339
20340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20341         LDKRecoverableSignature o_ref;
20342         CHECK((*env)->GetArrayLength(env, o) == 68);
20343         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
20344         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
20345         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
20346         return tag_ptr(ret_conv, true);
20347 }
20348
20349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
20350         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
20351         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
20352         return tag_ptr(ret_conv, true);
20353 }
20354
20355 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20356         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(o);
20357         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
20358         return ret_conv;
20359 }
20360
20361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20362         if (!ptr_is_owned(_res)) return;
20363         void* _res_ptr = untag_ptr(_res);
20364         CHECK_ACCESS(_res_ptr);
20365         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
20366         FREE(untag_ptr(_res));
20367         CResult_RecoverableSignatureNoneZ_free(_res_conv);
20368 }
20369
20370 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
20371         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
20372         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
20373         return tag_ptr(ret_conv, true);
20374 }
20375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20376         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(arg);
20377         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
20378         return ret_conv;
20379 }
20380
20381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20382         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(orig);
20383         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
20384         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
20385         return tag_ptr(ret_conv, true);
20386 }
20387
20388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20389         void* o_ptr = untag_ptr(o);
20390         CHECK_ACCESS(o_ptr);
20391         LDKWriteableEcdsaChannelSigner o_conv = *(LDKWriteableEcdsaChannelSigner*)(o_ptr);
20392         if (o_conv.free == LDKWriteableEcdsaChannelSigner_JCalls_free) {
20393                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20394                 LDKWriteableEcdsaChannelSigner_JCalls_cloned(&o_conv);
20395         }
20396         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
20397         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(o_conv);
20398         return tag_ptr(ret_conv, true);
20399 }
20400
20401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20402         void* e_ptr = untag_ptr(e);
20403         CHECK_ACCESS(e_ptr);
20404         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20405         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20406         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
20407         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(e_conv);
20408         return tag_ptr(ret_conv, true);
20409 }
20410
20411 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20412         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* o_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(o);
20413         jboolean ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(o_conv);
20414         return ret_conv;
20415 }
20416
20417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20418         if (!ptr_is_owned(_res)) return;
20419         void* _res_ptr = untag_ptr(_res);
20420         CHECK_ACCESS(_res_ptr);
20421         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ _res_conv = *(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)(_res_ptr);
20422         FREE(untag_ptr(_res));
20423         CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(_res_conv);
20424 }
20425
20426 static inline uint64_t CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR arg) {
20427         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
20428         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(arg);
20429         return tag_ptr(ret_conv, true);
20430 }
20431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20432         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* arg_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(arg);
20433         int64_t ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(arg_conv);
20434         return ret_conv;
20435 }
20436
20437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20438         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* orig_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(orig);
20439         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
20440         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(orig_conv);
20441         return tag_ptr(ret_conv, true);
20442 }
20443
20444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
20445         LDKCVec_u8Z _res_ref;
20446         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
20447         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
20448         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
20449         CVec_u8Z_free(_res_ref);
20450 }
20451
20452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20453         LDKCVec_CVec_u8ZZ _res_constr;
20454         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20455         if (_res_constr.datalen > 0)
20456                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
20457         else
20458                 _res_constr.data = NULL;
20459         for (size_t i = 0; i < _res_constr.datalen; i++) {
20460                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
20461                 LDKCVec_u8Z _res_conv_8_ref;
20462                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
20463                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
20464                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
20465                 _res_constr.data[i] = _res_conv_8_ref;
20466         }
20467         CVec_CVec_u8ZZ_free(_res_constr);
20468 }
20469
20470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
20471         LDKCVec_CVec_u8ZZ o_constr;
20472         o_constr.datalen = (*env)->GetArrayLength(env, o);
20473         if (o_constr.datalen > 0)
20474                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
20475         else
20476                 o_constr.data = NULL;
20477         for (size_t i = 0; i < o_constr.datalen; i++) {
20478                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
20479                 LDKCVec_u8Z o_conv_8_ref;
20480                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
20481                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
20482                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
20483                 o_constr.data[i] = o_conv_8_ref;
20484         }
20485         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20486         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
20487         return tag_ptr(ret_conv, true);
20488 }
20489
20490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
20491         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20492         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
20493         return tag_ptr(ret_conv, true);
20494 }
20495
20496 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20497         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(o);
20498         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
20499         return ret_conv;
20500 }
20501
20502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20503         if (!ptr_is_owned(_res)) return;
20504         void* _res_ptr = untag_ptr(_res);
20505         CHECK_ACCESS(_res_ptr);
20506         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
20507         FREE(untag_ptr(_res));
20508         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
20509 }
20510
20511 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
20512         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20513         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
20514         return tag_ptr(ret_conv, true);
20515 }
20516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20517         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(arg);
20518         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
20519         return ret_conv;
20520 }
20521
20522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20523         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(orig);
20524         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20525         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
20526         return tag_ptr(ret_conv, true);
20527 }
20528
20529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20530         LDKInMemorySigner o_conv;
20531         o_conv.inner = untag_ptr(o);
20532         o_conv.is_owned = ptr_is_owned(o);
20533         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20534         o_conv = InMemorySigner_clone(&o_conv);
20535         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20536         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
20537         return tag_ptr(ret_conv, true);
20538 }
20539
20540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20541         void* e_ptr = untag_ptr(e);
20542         CHECK_ACCESS(e_ptr);
20543         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20544         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20545         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20546         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
20547         return tag_ptr(ret_conv, true);
20548 }
20549
20550 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20551         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(o);
20552         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
20553         return ret_conv;
20554 }
20555
20556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20557         if (!ptr_is_owned(_res)) return;
20558         void* _res_ptr = untag_ptr(_res);
20559         CHECK_ACCESS(_res_ptr);
20560         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
20561         FREE(untag_ptr(_res));
20562         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
20563 }
20564
20565 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
20566         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20567         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
20568         return tag_ptr(ret_conv, true);
20569 }
20570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20571         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(arg);
20572         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
20573         return ret_conv;
20574 }
20575
20576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20577         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(orig);
20578         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20579         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
20580         return tag_ptr(ret_conv, true);
20581 }
20582
20583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20584         LDKCVec_TxOutZ _res_constr;
20585         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20586         if (_res_constr.datalen > 0)
20587                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
20588         else
20589                 _res_constr.data = NULL;
20590         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20591         for (size_t h = 0; h < _res_constr.datalen; h++) {
20592                 int64_t _res_conv_7 = _res_vals[h];
20593                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
20594                 CHECK_ACCESS(_res_conv_7_ptr);
20595                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
20596                 FREE(untag_ptr(_res_conv_7));
20597                 _res_constr.data[h] = _res_conv_7_conv;
20598         }
20599         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20600         CVec_TxOutZ_free(_res_constr);
20601 }
20602
20603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20604         LDKTransaction o_ref;
20605         o_ref.datalen = (*env)->GetArrayLength(env, o);
20606         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
20607         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
20608         o_ref.data_is_owned = true;
20609         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20610         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
20611         return tag_ptr(ret_conv, true);
20612 }
20613
20614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
20615         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20616         *ret_conv = CResult_TransactionNoneZ_err();
20617         return tag_ptr(ret_conv, true);
20618 }
20619
20620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20621         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(o);
20622         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
20623         return ret_conv;
20624 }
20625
20626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20627         if (!ptr_is_owned(_res)) return;
20628         void* _res_ptr = untag_ptr(_res);
20629         CHECK_ACCESS(_res_ptr);
20630         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
20631         FREE(untag_ptr(_res));
20632         CResult_TransactionNoneZ_free(_res_conv);
20633 }
20634
20635 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
20636         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20637         *ret_conv = CResult_TransactionNoneZ_clone(arg);
20638         return tag_ptr(ret_conv, true);
20639 }
20640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20641         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(arg);
20642         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
20643         return ret_conv;
20644 }
20645
20646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20647         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(orig);
20648         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20649         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
20650         return tag_ptr(ret_conv, true);
20651 }
20652
20653 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
20654         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
20655         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
20656         return tag_ptr(ret_conv, true);
20657 }
20658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20659         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(arg);
20660         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
20661         return ret_conv;
20662 }
20663
20664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20665         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(orig);
20666         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
20667         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
20668         return tag_ptr(ret_conv, true);
20669 }
20670
20671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
20672         LDKThirtyTwoBytes a_ref;
20673         CHECK((*env)->GetArrayLength(env, a) == 32);
20674         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20675         LDKChannelMonitor b_conv;
20676         b_conv.inner = untag_ptr(b);
20677         b_conv.is_owned = ptr_is_owned(b);
20678         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
20679         b_conv = ChannelMonitor_clone(&b_conv);
20680         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
20681         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
20682         return tag_ptr(ret_conv, true);
20683 }
20684
20685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20686         if (!ptr_is_owned(_res)) return;
20687         void* _res_ptr = untag_ptr(_res);
20688         CHECK_ACCESS(_res_ptr);
20689         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
20690         FREE(untag_ptr(_res));
20691         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
20692 }
20693
20694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20695         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _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(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
20699         else
20700                 _res_constr.data = NULL;
20701         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20702         for (size_t j = 0; j < _res_constr.datalen; j++) {
20703                 int64_t _res_conv_35 = _res_vals[j];
20704                 void* _res_conv_35_ptr = untag_ptr(_res_conv_35);
20705                 CHECK_ACCESS(_res_conv_35_ptr);
20706                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
20707                 FREE(untag_ptr(_res_conv_35));
20708                 _res_constr.data[j] = _res_conv_35_conv;
20709         }
20710         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20711         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
20712 }
20713
20714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
20715         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
20716         o_constr.datalen = (*env)->GetArrayLength(env, o);
20717         if (o_constr.datalen > 0)
20718                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
20719         else
20720                 o_constr.data = NULL;
20721         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
20722         for (size_t j = 0; j < o_constr.datalen; j++) {
20723                 int64_t o_conv_35 = o_vals[j];
20724                 void* o_conv_35_ptr = untag_ptr(o_conv_35);
20725                 CHECK_ACCESS(o_conv_35_ptr);
20726                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
20727                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o_conv_35));
20728                 o_constr.data[j] = o_conv_35_conv;
20729         }
20730         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
20731         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20732         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
20733         return tag_ptr(ret_conv, true);
20734 }
20735
20736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20737         LDKIOError e_conv = LDKIOError_from_java(env, e);
20738         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20739         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
20740         return tag_ptr(ret_conv, true);
20741 }
20742
20743 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20744         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(o);
20745         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
20746         return ret_conv;
20747 }
20748
20749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20750         if (!ptr_is_owned(_res)) return;
20751         void* _res_ptr = untag_ptr(_res);
20752         CHECK_ACCESS(_res_ptr);
20753         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
20754         FREE(untag_ptr(_res));
20755         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
20756 }
20757
20758 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
20759         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20760         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
20761         return tag_ptr(ret_conv, true);
20762 }
20763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20764         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(arg);
20765         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
20766         return ret_conv;
20767 }
20768
20769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20770         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(orig);
20771         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20772         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
20773         return tag_ptr(ret_conv, true);
20774 }
20775
20776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
20777         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20778         *ret_copy = COption_u16Z_some(o);
20779         int64_t ret_ref = tag_ptr(ret_copy, true);
20780         return ret_ref;
20781 }
20782
20783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
20784         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20785         *ret_copy = COption_u16Z_none();
20786         int64_t ret_ref = tag_ptr(ret_copy, true);
20787         return ret_ref;
20788 }
20789
20790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
20791         if (!ptr_is_owned(_res)) return;
20792         void* _res_ptr = untag_ptr(_res);
20793         CHECK_ACCESS(_res_ptr);
20794         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
20795         FREE(untag_ptr(_res));
20796         COption_u16Z_free(_res_conv);
20797 }
20798
20799 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
20800         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20801         *ret_copy = COption_u16Z_clone(arg);
20802         int64_t ret_ref = tag_ptr(ret_copy, true);
20803         return ret_ref;
20804 }
20805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20806         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)untag_ptr(arg);
20807         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
20808         return ret_conv;
20809 }
20810
20811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20812         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)untag_ptr(orig);
20813         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20814         *ret_copy = COption_u16Z_clone(orig_conv);
20815         int64_t ret_ref = tag_ptr(ret_copy, true);
20816         return ret_ref;
20817 }
20818
20819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20820         LDKThirtyTwoBytes o_ref;
20821         CHECK((*env)->GetArrayLength(env, o) == 32);
20822         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20823         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20824         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
20825         return tag_ptr(ret_conv, true);
20826 }
20827
20828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20829         void* e_ptr = untag_ptr(e);
20830         CHECK_ACCESS(e_ptr);
20831         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20832         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20833         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20834         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
20835         return tag_ptr(ret_conv, true);
20836 }
20837
20838 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20839         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(o);
20840         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
20841         return ret_conv;
20842 }
20843
20844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20845         if (!ptr_is_owned(_res)) return;
20846         void* _res_ptr = untag_ptr(_res);
20847         CHECK_ACCESS(_res_ptr);
20848         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
20849         FREE(untag_ptr(_res));
20850         CResult__u832APIErrorZ_free(_res_conv);
20851 }
20852
20853 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
20854         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20855         *ret_conv = CResult__u832APIErrorZ_clone(arg);
20856         return tag_ptr(ret_conv, true);
20857 }
20858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20859         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(arg);
20860         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
20861         return ret_conv;
20862 }
20863
20864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20865         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(orig);
20866         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20867         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
20868         return tag_ptr(ret_conv, true);
20869 }
20870
20871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RecentPaymentDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20872         LDKCVec_RecentPaymentDetailsZ _res_constr;
20873         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20874         if (_res_constr.datalen > 0)
20875                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRecentPaymentDetails), "LDKCVec_RecentPaymentDetailsZ Elements");
20876         else
20877                 _res_constr.data = NULL;
20878         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20879         for (size_t w = 0; w < _res_constr.datalen; w++) {
20880                 int64_t _res_conv_22 = _res_vals[w];
20881                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
20882                 CHECK_ACCESS(_res_conv_22_ptr);
20883                 LDKRecentPaymentDetails _res_conv_22_conv = *(LDKRecentPaymentDetails*)(_res_conv_22_ptr);
20884                 FREE(untag_ptr(_res_conv_22));
20885                 _res_constr.data[w] = _res_conv_22_conv;
20886         }
20887         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20888         CVec_RecentPaymentDetailsZ_free(_res_constr);
20889 }
20890
20891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
20892         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20893         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
20894         return tag_ptr(ret_conv, true);
20895 }
20896
20897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20898         void* e_ptr = untag_ptr(e);
20899         CHECK_ACCESS(e_ptr);
20900         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20901         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20902         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20903         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
20904         return tag_ptr(ret_conv, true);
20905 }
20906
20907 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20908         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(o);
20909         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
20910         return ret_conv;
20911 }
20912
20913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20914         if (!ptr_is_owned(_res)) return;
20915         void* _res_ptr = untag_ptr(_res);
20916         CHECK_ACCESS(_res_ptr);
20917         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
20918         FREE(untag_ptr(_res));
20919         CResult_NonePaymentSendFailureZ_free(_res_conv);
20920 }
20921
20922 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
20923         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20924         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
20925         return tag_ptr(ret_conv, true);
20926 }
20927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20928         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(arg);
20929         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
20930         return ret_conv;
20931 }
20932
20933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20934         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(orig);
20935         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20936         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
20937         return tag_ptr(ret_conv, true);
20938 }
20939
20940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1ok(JNIEnv *env, jclass clz) {
20941         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
20942         *ret_conv = CResult_NoneRetryableSendFailureZ_ok();
20943         return tag_ptr(ret_conv, true);
20944 }
20945
20946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1err(JNIEnv *env, jclass clz, jclass e) {
20947         LDKRetryableSendFailure e_conv = LDKRetryableSendFailure_from_java(env, e);
20948         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
20949         *ret_conv = CResult_NoneRetryableSendFailureZ_err(e_conv);
20950         return tag_ptr(ret_conv, true);
20951 }
20952
20953 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20954         LDKCResult_NoneRetryableSendFailureZ* o_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(o);
20955         jboolean ret_conv = CResult_NoneRetryableSendFailureZ_is_ok(o_conv);
20956         return ret_conv;
20957 }
20958
20959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20960         if (!ptr_is_owned(_res)) return;
20961         void* _res_ptr = untag_ptr(_res);
20962         CHECK_ACCESS(_res_ptr);
20963         LDKCResult_NoneRetryableSendFailureZ _res_conv = *(LDKCResult_NoneRetryableSendFailureZ*)(_res_ptr);
20964         FREE(untag_ptr(_res));
20965         CResult_NoneRetryableSendFailureZ_free(_res_conv);
20966 }
20967
20968 static inline uint64_t CResult_NoneRetryableSendFailureZ_clone_ptr(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR arg) {
20969         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
20970         *ret_conv = CResult_NoneRetryableSendFailureZ_clone(arg);
20971         return tag_ptr(ret_conv, true);
20972 }
20973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20974         LDKCResult_NoneRetryableSendFailureZ* arg_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(arg);
20975         int64_t ret_conv = CResult_NoneRetryableSendFailureZ_clone_ptr(arg_conv);
20976         return ret_conv;
20977 }
20978
20979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20980         LDKCResult_NoneRetryableSendFailureZ* orig_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(orig);
20981         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
20982         *ret_conv = CResult_NoneRetryableSendFailureZ_clone(orig_conv);
20983         return tag_ptr(ret_conv, true);
20984 }
20985
20986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20987         LDKThirtyTwoBytes o_ref;
20988         CHECK((*env)->GetArrayLength(env, o) == 32);
20989         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20990         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
20991         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref);
20992         return tag_ptr(ret_conv, true);
20993 }
20994
20995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20996         void* e_ptr = untag_ptr(e);
20997         CHECK_ACCESS(e_ptr);
20998         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20999         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21000         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21001         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv);
21002         return tag_ptr(ret_conv, true);
21003 }
21004
21005 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21006         LDKCResult_PaymentHashPaymentSendFailureZ* o_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(o);
21007         jboolean ret_conv = CResult_PaymentHashPaymentSendFailureZ_is_ok(o_conv);
21008         return ret_conv;
21009 }
21010
21011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21012         if (!ptr_is_owned(_res)) return;
21013         void* _res_ptr = untag_ptr(_res);
21014         CHECK_ACCESS(_res_ptr);
21015         LDKCResult_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(_res_ptr);
21016         FREE(untag_ptr(_res));
21017         CResult_PaymentHashPaymentSendFailureZ_free(_res_conv);
21018 }
21019
21020 static inline uint64_t CResult_PaymentHashPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR arg) {
21021         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21022         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(arg);
21023         return tag_ptr(ret_conv, true);
21024 }
21025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21026         LDKCResult_PaymentHashPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(arg);
21027         int64_t ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone_ptr(arg_conv);
21028         return ret_conv;
21029 }
21030
21031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21032         LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(orig);
21033         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21034         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv);
21035         return tag_ptr(ret_conv, true);
21036 }
21037
21038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21039         LDKThirtyTwoBytes o_ref;
21040         CHECK((*env)->GetArrayLength(env, o) == 32);
21041         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21042         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21043         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_ok(o_ref);
21044         return tag_ptr(ret_conv, true);
21045 }
21046
21047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1err(JNIEnv *env, jclass clz, jclass e) {
21048         LDKRetryableSendFailure e_conv = LDKRetryableSendFailure_from_java(env, e);
21049         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21050         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_err(e_conv);
21051         return tag_ptr(ret_conv, true);
21052 }
21053
21054 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21055         LDKCResult_PaymentHashRetryableSendFailureZ* o_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(o);
21056         jboolean ret_conv = CResult_PaymentHashRetryableSendFailureZ_is_ok(o_conv);
21057         return ret_conv;
21058 }
21059
21060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21061         if (!ptr_is_owned(_res)) return;
21062         void* _res_ptr = untag_ptr(_res);
21063         CHECK_ACCESS(_res_ptr);
21064         LDKCResult_PaymentHashRetryableSendFailureZ _res_conv = *(LDKCResult_PaymentHashRetryableSendFailureZ*)(_res_ptr);
21065         FREE(untag_ptr(_res));
21066         CResult_PaymentHashRetryableSendFailureZ_free(_res_conv);
21067 }
21068
21069 static inline uint64_t CResult_PaymentHashRetryableSendFailureZ_clone_ptr(LDKCResult_PaymentHashRetryableSendFailureZ *NONNULL_PTR arg) {
21070         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21071         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_clone(arg);
21072         return tag_ptr(ret_conv, true);
21073 }
21074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21075         LDKCResult_PaymentHashRetryableSendFailureZ* arg_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(arg);
21076         int64_t ret_conv = CResult_PaymentHashRetryableSendFailureZ_clone_ptr(arg_conv);
21077         return ret_conv;
21078 }
21079
21080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21081         LDKCResult_PaymentHashRetryableSendFailureZ* orig_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(orig);
21082         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21083         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_clone(orig_conv);
21084         return tag_ptr(ret_conv, true);
21085 }
21086
21087 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
21088         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21089         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
21090         return tag_ptr(ret_conv, true);
21091 }
21092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21093         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(arg);
21094         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
21095         return ret_conv;
21096 }
21097
21098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21099         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(orig);
21100         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21101         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
21102         return tag_ptr(ret_conv, true);
21103 }
21104
21105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
21106         LDKThirtyTwoBytes a_ref;
21107         CHECK((*env)->GetArrayLength(env, a) == 32);
21108         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21109         LDKThirtyTwoBytes b_ref;
21110         CHECK((*env)->GetArrayLength(env, b) == 32);
21111         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21112         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21113         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
21114         return tag_ptr(ret_conv, true);
21115 }
21116
21117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21118         if (!ptr_is_owned(_res)) return;
21119         void* _res_ptr = untag_ptr(_res);
21120         CHECK_ACCESS(_res_ptr);
21121         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
21122         FREE(untag_ptr(_res));
21123         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
21124 }
21125
21126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21127         void* o_ptr = untag_ptr(o);
21128         CHECK_ACCESS(o_ptr);
21129         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
21130         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(o));
21131         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21132         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
21133         return tag_ptr(ret_conv, true);
21134 }
21135
21136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21137         void* e_ptr = untag_ptr(e);
21138         CHECK_ACCESS(e_ptr);
21139         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21140         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21141         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21142         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
21143         return tag_ptr(ret_conv, true);
21144 }
21145
21146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21147         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(o);
21148         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
21149         return ret_conv;
21150 }
21151
21152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21153         if (!ptr_is_owned(_res)) return;
21154         void* _res_ptr = untag_ptr(_res);
21155         CHECK_ACCESS(_res_ptr);
21156         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
21157         FREE(untag_ptr(_res));
21158         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
21159 }
21160
21161 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
21162         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21163         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
21164         return tag_ptr(ret_conv, true);
21165 }
21166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21167         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(arg);
21168         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
21169         return ret_conv;
21170 }
21171
21172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21173         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(orig);
21174         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21175         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
21176         return tag_ptr(ret_conv, true);
21177 }
21178
21179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21180         LDKCVec_ThirtyTwoBytesZ _res_constr;
21181         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21182         if (_res_constr.datalen > 0)
21183                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
21184         else
21185                 _res_constr.data = NULL;
21186         for (size_t i = 0; i < _res_constr.datalen; i++) {
21187                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21188                 LDKThirtyTwoBytes _res_conv_8_ref;
21189                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
21190                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
21191                 _res_constr.data[i] = _res_conv_8_ref;
21192         }
21193         CVec_ThirtyTwoBytesZ_free(_res_constr);
21194 }
21195
21196 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
21197         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21198         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
21199         return tag_ptr(ret_conv, true);
21200 }
21201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21202         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(arg);
21203         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
21204         return ret_conv;
21205 }
21206
21207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21208         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(orig);
21209         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21210         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
21211         return tag_ptr(ret_conv, true);
21212 }
21213
21214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
21215         LDKThirtyTwoBytes a_ref;
21216         CHECK((*env)->GetArrayLength(env, a) == 32);
21217         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21218         LDKThirtyTwoBytes b_ref;
21219         CHECK((*env)->GetArrayLength(env, b) == 32);
21220         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21221         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21222         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
21223         return tag_ptr(ret_conv, true);
21224 }
21225
21226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21227         if (!ptr_is_owned(_res)) return;
21228         void* _res_ptr = untag_ptr(_res);
21229         CHECK_ACCESS(_res_ptr);
21230         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
21231         FREE(untag_ptr(_res));
21232         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
21233 }
21234
21235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21236         void* o_ptr = untag_ptr(o);
21237         CHECK_ACCESS(o_ptr);
21238         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
21239         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
21240         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21241         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
21242         return tag_ptr(ret_conv, true);
21243 }
21244
21245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
21246         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21247         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
21248         return tag_ptr(ret_conv, true);
21249 }
21250
21251 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21252         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(o);
21253         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
21254         return ret_conv;
21255 }
21256
21257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21258         if (!ptr_is_owned(_res)) return;
21259         void* _res_ptr = untag_ptr(_res);
21260         CHECK_ACCESS(_res_ptr);
21261         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
21262         FREE(untag_ptr(_res));
21263         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
21264 }
21265
21266 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
21267         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21268         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
21269         return tag_ptr(ret_conv, true);
21270 }
21271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21272         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(arg);
21273         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
21274         return ret_conv;
21275 }
21276
21277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21278         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(orig);
21279         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21280         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
21281         return tag_ptr(ret_conv, true);
21282 }
21283
21284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21285         void* o_ptr = untag_ptr(o);
21286         CHECK_ACCESS(o_ptr);
21287         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
21288         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
21289         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21290         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
21291         return tag_ptr(ret_conv, true);
21292 }
21293
21294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21295         void* e_ptr = untag_ptr(e);
21296         CHECK_ACCESS(e_ptr);
21297         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21298         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21299         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21300         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
21301         return tag_ptr(ret_conv, true);
21302 }
21303
21304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21305         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(o);
21306         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
21307         return ret_conv;
21308 }
21309
21310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21311         if (!ptr_is_owned(_res)) return;
21312         void* _res_ptr = untag_ptr(_res);
21313         CHECK_ACCESS(_res_ptr);
21314         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
21315         FREE(untag_ptr(_res));
21316         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
21317 }
21318
21319 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
21320         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21321         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
21322         return tag_ptr(ret_conv, true);
21323 }
21324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21325         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(arg);
21326         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
21327         return ret_conv;
21328 }
21329
21330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21331         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(orig);
21332         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21333         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
21334         return tag_ptr(ret_conv, true);
21335 }
21336
21337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21338         LDKThirtyTwoBytes o_ref;
21339         CHECK((*env)->GetArrayLength(env, o) == 32);
21340         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21341         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21342         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
21343         return tag_ptr(ret_conv, true);
21344 }
21345
21346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
21347         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21348         *ret_conv = CResult_PaymentSecretNoneZ_err();
21349         return tag_ptr(ret_conv, true);
21350 }
21351
21352 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21353         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(o);
21354         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
21355         return ret_conv;
21356 }
21357
21358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21359         if (!ptr_is_owned(_res)) return;
21360         void* _res_ptr = untag_ptr(_res);
21361         CHECK_ACCESS(_res_ptr);
21362         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
21363         FREE(untag_ptr(_res));
21364         CResult_PaymentSecretNoneZ_free(_res_conv);
21365 }
21366
21367 static inline uint64_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
21368         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21369         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
21370         return tag_ptr(ret_conv, true);
21371 }
21372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21373         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(arg);
21374         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
21375         return ret_conv;
21376 }
21377
21378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21379         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(orig);
21380         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21381         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
21382         return tag_ptr(ret_conv, true);
21383 }
21384
21385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21386         LDKThirtyTwoBytes o_ref;
21387         CHECK((*env)->GetArrayLength(env, o) == 32);
21388         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21389         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
21390         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
21391         return tag_ptr(ret_conv, true);
21392 }
21393
21394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21395         void* e_ptr = untag_ptr(e);
21396         CHECK_ACCESS(e_ptr);
21397         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21398         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21399         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
21400         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
21401         return tag_ptr(ret_conv, true);
21402 }
21403
21404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21405         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(o);
21406         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
21407         return ret_conv;
21408 }
21409
21410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21411         if (!ptr_is_owned(_res)) return;
21412         void* _res_ptr = untag_ptr(_res);
21413         CHECK_ACCESS(_res_ptr);
21414         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
21415         FREE(untag_ptr(_res));
21416         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
21417 }
21418
21419 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
21420         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
21421         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
21422         return tag_ptr(ret_conv, true);
21423 }
21424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21425         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(arg);
21426         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
21427         return ret_conv;
21428 }
21429
21430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21431         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(orig);
21432         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
21433         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
21434         return tag_ptr(ret_conv, true);
21435 }
21436
21437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21438         LDKThirtyTwoBytes o_ref;
21439         CHECK((*env)->GetArrayLength(env, o) == 32);
21440         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21441         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
21442         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
21443         return tag_ptr(ret_conv, true);
21444 }
21445
21446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21447         void* e_ptr = untag_ptr(e);
21448         CHECK_ACCESS(e_ptr);
21449         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21450         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21451         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
21452         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
21453         return tag_ptr(ret_conv, true);
21454 }
21455
21456 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21457         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(o);
21458         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
21459         return ret_conv;
21460 }
21461
21462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21463         if (!ptr_is_owned(_res)) return;
21464         void* _res_ptr = untag_ptr(_res);
21465         CHECK_ACCESS(_res_ptr);
21466         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
21467         FREE(untag_ptr(_res));
21468         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
21469 }
21470
21471 static inline uint64_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
21472         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
21473         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
21474         return tag_ptr(ret_conv, true);
21475 }
21476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21477         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(arg);
21478         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
21479         return ret_conv;
21480 }
21481
21482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21483         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(orig);
21484         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
21485         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
21486         return tag_ptr(ret_conv, true);
21487 }
21488
21489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21490         LDKCounterpartyForwardingInfo o_conv;
21491         o_conv.inner = untag_ptr(o);
21492         o_conv.is_owned = ptr_is_owned(o);
21493         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21494         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
21495         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21496         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
21497         return tag_ptr(ret_conv, true);
21498 }
21499
21500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21501         void* e_ptr = untag_ptr(e);
21502         CHECK_ACCESS(e_ptr);
21503         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21504         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21505         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21506         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
21507         return tag_ptr(ret_conv, true);
21508 }
21509
21510 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21511         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(o);
21512         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
21513         return ret_conv;
21514 }
21515
21516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21517         if (!ptr_is_owned(_res)) return;
21518         void* _res_ptr = untag_ptr(_res);
21519         CHECK_ACCESS(_res_ptr);
21520         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
21521         FREE(untag_ptr(_res));
21522         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
21523 }
21524
21525 static inline uint64_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
21526         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21527         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
21528         return tag_ptr(ret_conv, true);
21529 }
21530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21531         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(arg);
21532         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
21533         return ret_conv;
21534 }
21535
21536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21537         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(orig);
21538         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21539         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
21540         return tag_ptr(ret_conv, true);
21541 }
21542
21543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21544         LDKChannelCounterparty o_conv;
21545         o_conv.inner = untag_ptr(o);
21546         o_conv.is_owned = ptr_is_owned(o);
21547         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21548         o_conv = ChannelCounterparty_clone(&o_conv);
21549         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21550         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
21551         return tag_ptr(ret_conv, true);
21552 }
21553
21554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21555         void* e_ptr = untag_ptr(e);
21556         CHECK_ACCESS(e_ptr);
21557         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21558         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21559         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21560         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
21561         return tag_ptr(ret_conv, true);
21562 }
21563
21564 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21565         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(o);
21566         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
21567         return ret_conv;
21568 }
21569
21570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21571         if (!ptr_is_owned(_res)) return;
21572         void* _res_ptr = untag_ptr(_res);
21573         CHECK_ACCESS(_res_ptr);
21574         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
21575         FREE(untag_ptr(_res));
21576         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
21577 }
21578
21579 static inline uint64_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
21580         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21581         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
21582         return tag_ptr(ret_conv, true);
21583 }
21584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21585         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(arg);
21586         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
21587         return ret_conv;
21588 }
21589
21590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21591         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(orig);
21592         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21593         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
21594         return tag_ptr(ret_conv, true);
21595 }
21596
21597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21598         LDKChannelDetails o_conv;
21599         o_conv.inner = untag_ptr(o);
21600         o_conv.is_owned = ptr_is_owned(o);
21601         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21602         o_conv = ChannelDetails_clone(&o_conv);
21603         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21604         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
21605         return tag_ptr(ret_conv, true);
21606 }
21607
21608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21609         void* e_ptr = untag_ptr(e);
21610         CHECK_ACCESS(e_ptr);
21611         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21612         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21613         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21614         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
21615         return tag_ptr(ret_conv, true);
21616 }
21617
21618 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21619         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(o);
21620         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
21621         return ret_conv;
21622 }
21623
21624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21625         if (!ptr_is_owned(_res)) return;
21626         void* _res_ptr = untag_ptr(_res);
21627         CHECK_ACCESS(_res_ptr);
21628         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
21629         FREE(untag_ptr(_res));
21630         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
21631 }
21632
21633 static inline uint64_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
21634         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21635         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
21636         return tag_ptr(ret_conv, true);
21637 }
21638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21639         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(arg);
21640         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
21641         return ret_conv;
21642 }
21643
21644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21645         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(orig);
21646         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21647         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
21648         return tag_ptr(ret_conv, true);
21649 }
21650
21651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21652         LDKPhantomRouteHints o_conv;
21653         o_conv.inner = untag_ptr(o);
21654         o_conv.is_owned = ptr_is_owned(o);
21655         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21656         o_conv = PhantomRouteHints_clone(&o_conv);
21657         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21658         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
21659         return tag_ptr(ret_conv, true);
21660 }
21661
21662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21663         void* e_ptr = untag_ptr(e);
21664         CHECK_ACCESS(e_ptr);
21665         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21666         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21667         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21668         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
21669         return tag_ptr(ret_conv, true);
21670 }
21671
21672 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21673         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(o);
21674         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
21675         return ret_conv;
21676 }
21677
21678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21679         if (!ptr_is_owned(_res)) return;
21680         void* _res_ptr = untag_ptr(_res);
21681         CHECK_ACCESS(_res_ptr);
21682         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
21683         FREE(untag_ptr(_res));
21684         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
21685 }
21686
21687 static inline uint64_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
21688         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21689         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
21690         return tag_ptr(ret_conv, true);
21691 }
21692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21693         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(arg);
21694         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
21695         return ret_conv;
21696 }
21697
21698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21699         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(orig);
21700         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21701         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
21702         return tag_ptr(ret_conv, true);
21703 }
21704
21705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21706         LDKCVec_ChannelMonitorZ _res_constr;
21707         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21708         if (_res_constr.datalen > 0)
21709                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
21710         else
21711                 _res_constr.data = NULL;
21712         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21713         for (size_t q = 0; q < _res_constr.datalen; q++) {
21714                 int64_t _res_conv_16 = _res_vals[q];
21715                 LDKChannelMonitor _res_conv_16_conv;
21716                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
21717                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
21718                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
21719                 _res_constr.data[q] = _res_conv_16_conv;
21720         }
21721         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21722         CVec_ChannelMonitorZ_free(_res_constr);
21723 }
21724
21725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
21726         LDKThirtyTwoBytes a_ref;
21727         CHECK((*env)->GetArrayLength(env, a) == 32);
21728         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21729         LDKChannelManager b_conv;
21730         b_conv.inner = untag_ptr(b);
21731         b_conv.is_owned = ptr_is_owned(b);
21732         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21733         // WARNING: we need a move here but no clone is available for LDKChannelManager
21734         
21735         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
21736         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
21737         return tag_ptr(ret_conv, true);
21738 }
21739
21740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21741         if (!ptr_is_owned(_res)) return;
21742         void* _res_ptr = untag_ptr(_res);
21743         CHECK_ACCESS(_res_ptr);
21744         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
21745         FREE(untag_ptr(_res));
21746         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
21747 }
21748
21749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21750         void* o_ptr = untag_ptr(o);
21751         CHECK_ACCESS(o_ptr);
21752         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
21753         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
21754         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
21755         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
21756         return tag_ptr(ret_conv, true);
21757 }
21758
21759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21760         void* e_ptr = untag_ptr(e);
21761         CHECK_ACCESS(e_ptr);
21762         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21763         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21764         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
21765         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
21766         return tag_ptr(ret_conv, true);
21767 }
21768
21769 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21770         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(o);
21771         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
21772         return ret_conv;
21773 }
21774
21775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21776         if (!ptr_is_owned(_res)) return;
21777         void* _res_ptr = untag_ptr(_res);
21778         CHECK_ACCESS(_res_ptr);
21779         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
21780         FREE(untag_ptr(_res));
21781         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
21782 }
21783
21784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21785         LDKChannelConfig o_conv;
21786         o_conv.inner = untag_ptr(o);
21787         o_conv.is_owned = ptr_is_owned(o);
21788         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21789         o_conv = ChannelConfig_clone(&o_conv);
21790         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21791         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
21792         return tag_ptr(ret_conv, true);
21793 }
21794
21795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21796         void* e_ptr = untag_ptr(e);
21797         CHECK_ACCESS(e_ptr);
21798         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21799         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21800         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21801         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
21802         return tag_ptr(ret_conv, true);
21803 }
21804
21805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21806         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(o);
21807         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
21808         return ret_conv;
21809 }
21810
21811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21812         if (!ptr_is_owned(_res)) return;
21813         void* _res_ptr = untag_ptr(_res);
21814         CHECK_ACCESS(_res_ptr);
21815         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
21816         FREE(untag_ptr(_res));
21817         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
21818 }
21819
21820 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
21821         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21822         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
21823         return tag_ptr(ret_conv, true);
21824 }
21825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21826         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(arg);
21827         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
21828         return ret_conv;
21829 }
21830
21831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21832         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(orig);
21833         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21834         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
21835         return tag_ptr(ret_conv, true);
21836 }
21837
21838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21839         void* o_ptr = untag_ptr(o);
21840         CHECK_ACCESS(o_ptr);
21841         LDKAPIError o_conv = *(LDKAPIError*)(o_ptr);
21842         o_conv = APIError_clone((LDKAPIError*)untag_ptr(o));
21843         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
21844         *ret_copy = COption_APIErrorZ_some(o_conv);
21845         int64_t ret_ref = tag_ptr(ret_copy, true);
21846         return ret_ref;
21847 }
21848
21849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1none(JNIEnv *env, jclass clz) {
21850         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
21851         *ret_copy = COption_APIErrorZ_none();
21852         int64_t ret_ref = tag_ptr(ret_copy, true);
21853         return ret_ref;
21854 }
21855
21856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21857         if (!ptr_is_owned(_res)) return;
21858         void* _res_ptr = untag_ptr(_res);
21859         CHECK_ACCESS(_res_ptr);
21860         LDKCOption_APIErrorZ _res_conv = *(LDKCOption_APIErrorZ*)(_res_ptr);
21861         FREE(untag_ptr(_res));
21862         COption_APIErrorZ_free(_res_conv);
21863 }
21864
21865 static inline uint64_t COption_APIErrorZ_clone_ptr(LDKCOption_APIErrorZ *NONNULL_PTR arg) {
21866         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
21867         *ret_copy = COption_APIErrorZ_clone(arg);
21868         int64_t ret_ref = tag_ptr(ret_copy, true);
21869         return ret_ref;
21870 }
21871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21872         LDKCOption_APIErrorZ* arg_conv = (LDKCOption_APIErrorZ*)untag_ptr(arg);
21873         int64_t ret_conv = COption_APIErrorZ_clone_ptr(arg_conv);
21874         return ret_conv;
21875 }
21876
21877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21878         LDKCOption_APIErrorZ* orig_conv = (LDKCOption_APIErrorZ*)untag_ptr(orig);
21879         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
21880         *ret_copy = COption_APIErrorZ_clone(orig_conv);
21881         int64_t ret_ref = tag_ptr(ret_copy, true);
21882         return ret_ref;
21883 }
21884
21885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21886         void* o_ptr = untag_ptr(o);
21887         CHECK_ACCESS(o_ptr);
21888         LDKCOption_APIErrorZ o_conv = *(LDKCOption_APIErrorZ*)(o_ptr);
21889         o_conv = COption_APIErrorZ_clone((LDKCOption_APIErrorZ*)untag_ptr(o));
21890         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
21891         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_ok(o_conv);
21892         return tag_ptr(ret_conv, true);
21893 }
21894
21895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21896         void* e_ptr = untag_ptr(e);
21897         CHECK_ACCESS(e_ptr);
21898         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21899         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21900         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
21901         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_err(e_conv);
21902         return tag_ptr(ret_conv, true);
21903 }
21904
21905 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21906         LDKCResult_COption_APIErrorZDecodeErrorZ* o_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(o);
21907         jboolean ret_conv = CResult_COption_APIErrorZDecodeErrorZ_is_ok(o_conv);
21908         return ret_conv;
21909 }
21910
21911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21912         if (!ptr_is_owned(_res)) return;
21913         void* _res_ptr = untag_ptr(_res);
21914         CHECK_ACCESS(_res_ptr);
21915         LDKCResult_COption_APIErrorZDecodeErrorZ _res_conv = *(LDKCResult_COption_APIErrorZDecodeErrorZ*)(_res_ptr);
21916         FREE(untag_ptr(_res));
21917         CResult_COption_APIErrorZDecodeErrorZ_free(_res_conv);
21918 }
21919
21920 static inline uint64_t CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR arg) {
21921         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
21922         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone(arg);
21923         return tag_ptr(ret_conv, true);
21924 }
21925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21926         LDKCResult_COption_APIErrorZDecodeErrorZ* arg_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(arg);
21927         int64_t ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(arg_conv);
21928         return ret_conv;
21929 }
21930
21931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21932         LDKCResult_COption_APIErrorZDecodeErrorZ* orig_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(orig);
21933         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
21934         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone(orig_conv);
21935         return tag_ptr(ret_conv, true);
21936 }
21937
21938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21939         LDKOutPoint o_conv;
21940         o_conv.inner = untag_ptr(o);
21941         o_conv.is_owned = ptr_is_owned(o);
21942         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21943         o_conv = OutPoint_clone(&o_conv);
21944         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21945         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
21946         return tag_ptr(ret_conv, true);
21947 }
21948
21949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21950         void* e_ptr = untag_ptr(e);
21951         CHECK_ACCESS(e_ptr);
21952         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21953         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21954         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21955         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
21956         return tag_ptr(ret_conv, true);
21957 }
21958
21959 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21960         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(o);
21961         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
21962         return ret_conv;
21963 }
21964
21965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21966         if (!ptr_is_owned(_res)) return;
21967         void* _res_ptr = untag_ptr(_res);
21968         CHECK_ACCESS(_res_ptr);
21969         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
21970         FREE(untag_ptr(_res));
21971         CResult_OutPointDecodeErrorZ_free(_res_conv);
21972 }
21973
21974 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
21975         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21976         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
21977         return tag_ptr(ret_conv, true);
21978 }
21979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21980         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(arg);
21981         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
21982         return ret_conv;
21983 }
21984
21985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21986         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(orig);
21987         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21988         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
21989         return tag_ptr(ret_conv, true);
21990 }
21991
21992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21993         void* o_ptr = untag_ptr(o);
21994         CHECK_ACCESS(o_ptr);
21995         LDKType o_conv = *(LDKType*)(o_ptr);
21996         if (o_conv.free == LDKType_JCalls_free) {
21997                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21998                 LDKType_JCalls_cloned(&o_conv);
21999         }
22000         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22001         *ret_copy = COption_TypeZ_some(o_conv);
22002         int64_t ret_ref = tag_ptr(ret_copy, true);
22003         return ret_ref;
22004 }
22005
22006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
22007         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22008         *ret_copy = COption_TypeZ_none();
22009         int64_t ret_ref = tag_ptr(ret_copy, true);
22010         return ret_ref;
22011 }
22012
22013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22014         if (!ptr_is_owned(_res)) return;
22015         void* _res_ptr = untag_ptr(_res);
22016         CHECK_ACCESS(_res_ptr);
22017         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
22018         FREE(untag_ptr(_res));
22019         COption_TypeZ_free(_res_conv);
22020 }
22021
22022 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
22023         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22024         *ret_copy = COption_TypeZ_clone(arg);
22025         int64_t ret_ref = tag_ptr(ret_copy, true);
22026         return ret_ref;
22027 }
22028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22029         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)untag_ptr(arg);
22030         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
22031         return ret_conv;
22032 }
22033
22034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22035         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)untag_ptr(orig);
22036         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22037         *ret_copy = COption_TypeZ_clone(orig_conv);
22038         int64_t ret_ref = tag_ptr(ret_copy, true);
22039         return ret_ref;
22040 }
22041
22042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22043         void* o_ptr = untag_ptr(o);
22044         CHECK_ACCESS(o_ptr);
22045         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
22046         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)untag_ptr(o));
22047         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22048         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
22049         return tag_ptr(ret_conv, true);
22050 }
22051
22052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22053         void* e_ptr = untag_ptr(e);
22054         CHECK_ACCESS(e_ptr);
22055         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22056         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22057         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22058         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
22059         return tag_ptr(ret_conv, true);
22060 }
22061
22062 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22063         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(o);
22064         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
22065         return ret_conv;
22066 }
22067
22068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22069         if (!ptr_is_owned(_res)) return;
22070         void* _res_ptr = untag_ptr(_res);
22071         CHECK_ACCESS(_res_ptr);
22072         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
22073         FREE(untag_ptr(_res));
22074         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
22075 }
22076
22077 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
22078         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22079         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
22080         return tag_ptr(ret_conv, true);
22081 }
22082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22083         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(arg);
22084         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
22085         return ret_conv;
22086 }
22087
22088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22089         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(orig);
22090         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22091         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
22092         return tag_ptr(ret_conv, true);
22093 }
22094
22095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22096         LDKThirtyTwoBytes o_ref;
22097         CHECK((*env)->GetArrayLength(env, o) == 32);
22098         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
22099         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22100         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
22101         return tag_ptr(ret_conv, true);
22102 }
22103
22104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22105         void* e_ptr = untag_ptr(e);
22106         CHECK_ACCESS(e_ptr);
22107         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
22108         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
22109         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22110         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
22111         return tag_ptr(ret_conv, true);
22112 }
22113
22114 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22115         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(o);
22116         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
22117         return ret_conv;
22118 }
22119
22120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22121         if (!ptr_is_owned(_res)) return;
22122         void* _res_ptr = untag_ptr(_res);
22123         CHECK_ACCESS(_res_ptr);
22124         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
22125         FREE(untag_ptr(_res));
22126         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
22127 }
22128
22129 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
22130         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22131         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
22132         return tag_ptr(ret_conv, true);
22133 }
22134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22135         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(arg);
22136         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
22137         return ret_conv;
22138 }
22139
22140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22141         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(orig);
22142         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22143         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
22144         return tag_ptr(ret_conv, true);
22145 }
22146
22147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1ok(JNIEnv *env, jclass clz) {
22148         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22149         *ret_conv = CResult_NonePaymentErrorZ_ok();
22150         return tag_ptr(ret_conv, true);
22151 }
22152
22153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22154         void* e_ptr = untag_ptr(e);
22155         CHECK_ACCESS(e_ptr);
22156         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
22157         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
22158         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22159         *ret_conv = CResult_NonePaymentErrorZ_err(e_conv);
22160         return tag_ptr(ret_conv, true);
22161 }
22162
22163 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22164         LDKCResult_NonePaymentErrorZ* o_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(o);
22165         jboolean ret_conv = CResult_NonePaymentErrorZ_is_ok(o_conv);
22166         return ret_conv;
22167 }
22168
22169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22170         if (!ptr_is_owned(_res)) return;
22171         void* _res_ptr = untag_ptr(_res);
22172         CHECK_ACCESS(_res_ptr);
22173         LDKCResult_NonePaymentErrorZ _res_conv = *(LDKCResult_NonePaymentErrorZ*)(_res_ptr);
22174         FREE(untag_ptr(_res));
22175         CResult_NonePaymentErrorZ_free(_res_conv);
22176 }
22177
22178 static inline uint64_t CResult_NonePaymentErrorZ_clone_ptr(LDKCResult_NonePaymentErrorZ *NONNULL_PTR arg) {
22179         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22180         *ret_conv = CResult_NonePaymentErrorZ_clone(arg);
22181         return tag_ptr(ret_conv, true);
22182 }
22183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22184         LDKCResult_NonePaymentErrorZ* arg_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(arg);
22185         int64_t ret_conv = CResult_NonePaymentErrorZ_clone_ptr(arg_conv);
22186         return ret_conv;
22187 }
22188
22189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22190         LDKCResult_NonePaymentErrorZ* orig_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(orig);
22191         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22192         *ret_conv = CResult_NonePaymentErrorZ_clone(orig_conv);
22193         return tag_ptr(ret_conv, true);
22194 }
22195
22196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
22197         LDKStr o_conv = java_to_owned_str(env, o);
22198         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22199         *ret_conv = CResult_StringErrorZ_ok(o_conv);
22200         return tag_ptr(ret_conv, true);
22201 }
22202
22203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
22204         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
22205         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22206         *ret_conv = CResult_StringErrorZ_err(e_conv);
22207         return tag_ptr(ret_conv, true);
22208 }
22209
22210 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22211         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)untag_ptr(o);
22212         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
22213         return ret_conv;
22214 }
22215
22216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22217         if (!ptr_is_owned(_res)) return;
22218         void* _res_ptr = untag_ptr(_res);
22219         CHECK_ACCESS(_res_ptr);
22220         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
22221         FREE(untag_ptr(_res));
22222         CResult_StringErrorZ_free(_res_conv);
22223 }
22224
22225 static inline uint64_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
22226         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22227         *ret_conv = CResult_StringErrorZ_clone(arg);
22228         return tag_ptr(ret_conv, true);
22229 }
22230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22231         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)untag_ptr(arg);
22232         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
22233         return ret_conv;
22234 }
22235
22236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22237         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)untag_ptr(orig);
22238         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22239         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
22240         return tag_ptr(ret_conv, true);
22241 }
22242
22243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22244         LDKPublicKey o_ref;
22245         CHECK((*env)->GetArrayLength(env, o) == 33);
22246         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
22247         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22248         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
22249         return tag_ptr(ret_conv, true);
22250 }
22251
22252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
22253         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
22254         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22255         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
22256         return tag_ptr(ret_conv, true);
22257 }
22258
22259 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22260         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(o);
22261         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
22262         return ret_conv;
22263 }
22264
22265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22266         if (!ptr_is_owned(_res)) return;
22267         void* _res_ptr = untag_ptr(_res);
22268         CHECK_ACCESS(_res_ptr);
22269         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
22270         FREE(untag_ptr(_res));
22271         CResult_PublicKeyErrorZ_free(_res_conv);
22272 }
22273
22274 static inline uint64_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
22275         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22276         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
22277         return tag_ptr(ret_conv, true);
22278 }
22279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22280         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(arg);
22281         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
22282         return ret_conv;
22283 }
22284
22285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22286         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(orig);
22287         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22288         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
22289         return tag_ptr(ret_conv, true);
22290 }
22291
22292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22293         LDKChannelMonitorUpdate o_conv;
22294         o_conv.inner = untag_ptr(o);
22295         o_conv.is_owned = ptr_is_owned(o);
22296         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22297         o_conv = ChannelMonitorUpdate_clone(&o_conv);
22298         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22299         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
22300         return tag_ptr(ret_conv, true);
22301 }
22302
22303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22304         void* e_ptr = untag_ptr(e);
22305         CHECK_ACCESS(e_ptr);
22306         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22307         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22308         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22309         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
22310         return tag_ptr(ret_conv, true);
22311 }
22312
22313 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22314         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(o);
22315         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
22316         return ret_conv;
22317 }
22318
22319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22320         if (!ptr_is_owned(_res)) return;
22321         void* _res_ptr = untag_ptr(_res);
22322         CHECK_ACCESS(_res_ptr);
22323         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
22324         FREE(untag_ptr(_res));
22325         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
22326 }
22327
22328 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
22329         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22330         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
22331         return tag_ptr(ret_conv, true);
22332 }
22333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22334         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(arg);
22335         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
22336         return ret_conv;
22337 }
22338
22339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22340         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(orig);
22341         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22342         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
22343         return tag_ptr(ret_conv, true);
22344 }
22345
22346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22347         void* o_ptr = untag_ptr(o);
22348         CHECK_ACCESS(o_ptr);
22349         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
22350         o_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(o));
22351         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22352         *ret_copy = COption_MonitorEventZ_some(o_conv);
22353         int64_t ret_ref = tag_ptr(ret_copy, true);
22354         return ret_ref;
22355 }
22356
22357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
22358         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22359         *ret_copy = COption_MonitorEventZ_none();
22360         int64_t ret_ref = tag_ptr(ret_copy, true);
22361         return ret_ref;
22362 }
22363
22364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22365         if (!ptr_is_owned(_res)) return;
22366         void* _res_ptr = untag_ptr(_res);
22367         CHECK_ACCESS(_res_ptr);
22368         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
22369         FREE(untag_ptr(_res));
22370         COption_MonitorEventZ_free(_res_conv);
22371 }
22372
22373 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
22374         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22375         *ret_copy = COption_MonitorEventZ_clone(arg);
22376         int64_t ret_ref = tag_ptr(ret_copy, true);
22377         return ret_ref;
22378 }
22379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22380         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)untag_ptr(arg);
22381         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
22382         return ret_conv;
22383 }
22384
22385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22386         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)untag_ptr(orig);
22387         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22388         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
22389         int64_t ret_ref = tag_ptr(ret_copy, true);
22390         return ret_ref;
22391 }
22392
22393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22394         void* o_ptr = untag_ptr(o);
22395         CHECK_ACCESS(o_ptr);
22396         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
22397         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)untag_ptr(o));
22398         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22399         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
22400         return tag_ptr(ret_conv, true);
22401 }
22402
22403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22404         void* e_ptr = untag_ptr(e);
22405         CHECK_ACCESS(e_ptr);
22406         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22407         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22408         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22409         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
22410         return tag_ptr(ret_conv, true);
22411 }
22412
22413 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22414         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(o);
22415         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
22416         return ret_conv;
22417 }
22418
22419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22420         if (!ptr_is_owned(_res)) return;
22421         void* _res_ptr = untag_ptr(_res);
22422         CHECK_ACCESS(_res_ptr);
22423         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
22424         FREE(untag_ptr(_res));
22425         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
22426 }
22427
22428 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
22429         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22430         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
22431         return tag_ptr(ret_conv, true);
22432 }
22433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22434         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(arg);
22435         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
22436         return ret_conv;
22437 }
22438
22439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22440         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(orig);
22441         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22442         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
22443         return tag_ptr(ret_conv, true);
22444 }
22445
22446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22447         LDKHTLCUpdate o_conv;
22448         o_conv.inner = untag_ptr(o);
22449         o_conv.is_owned = ptr_is_owned(o);
22450         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22451         o_conv = HTLCUpdate_clone(&o_conv);
22452         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22453         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
22454         return tag_ptr(ret_conv, true);
22455 }
22456
22457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22458         void* e_ptr = untag_ptr(e);
22459         CHECK_ACCESS(e_ptr);
22460         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22461         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22462         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22463         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
22464         return tag_ptr(ret_conv, true);
22465 }
22466
22467 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22468         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(o);
22469         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
22470         return ret_conv;
22471 }
22472
22473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22474         if (!ptr_is_owned(_res)) return;
22475         void* _res_ptr = untag_ptr(_res);
22476         CHECK_ACCESS(_res_ptr);
22477         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
22478         FREE(untag_ptr(_res));
22479         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
22480 }
22481
22482 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
22483         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22484         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
22485         return tag_ptr(ret_conv, true);
22486 }
22487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22488         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(arg);
22489         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
22490         return ret_conv;
22491 }
22492
22493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22494         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(orig);
22495         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22496         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
22497         return tag_ptr(ret_conv, true);
22498 }
22499
22500 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
22501         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22502         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
22503         return tag_ptr(ret_conv, true);
22504 }
22505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22506         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(arg);
22507         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
22508         return ret_conv;
22509 }
22510
22511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22512         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(orig);
22513         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22514         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
22515         return tag_ptr(ret_conv, true);
22516 }
22517
22518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
22519         LDKOutPoint a_conv;
22520         a_conv.inner = untag_ptr(a);
22521         a_conv.is_owned = ptr_is_owned(a);
22522         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22523         a_conv = OutPoint_clone(&a_conv);
22524         LDKCVec_u8Z b_ref;
22525         b_ref.datalen = (*env)->GetArrayLength(env, b);
22526         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
22527         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
22528         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22529         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
22530         return tag_ptr(ret_conv, true);
22531 }
22532
22533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22534         if (!ptr_is_owned(_res)) return;
22535         void* _res_ptr = untag_ptr(_res);
22536         CHECK_ACCESS(_res_ptr);
22537         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
22538         FREE(untag_ptr(_res));
22539         C2Tuple_OutPointScriptZ_free(_res_conv);
22540 }
22541
22542 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
22543         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
22544         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
22545         return tag_ptr(ret_conv, true);
22546 }
22547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22548         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(arg);
22549         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
22550         return ret_conv;
22551 }
22552
22553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22554         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(orig);
22555         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
22556         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
22557         return tag_ptr(ret_conv, true);
22558 }
22559
22560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
22561         LDKCVec_u8Z b_ref;
22562         b_ref.datalen = (*env)->GetArrayLength(env, b);
22563         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
22564         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
22565         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
22566         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
22567         return tag_ptr(ret_conv, true);
22568 }
22569
22570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22571         if (!ptr_is_owned(_res)) return;
22572         void* _res_ptr = untag_ptr(_res);
22573         CHECK_ACCESS(_res_ptr);
22574         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
22575         FREE(untag_ptr(_res));
22576         C2Tuple_u32ScriptZ_free(_res_conv);
22577 }
22578
22579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22580         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
22581         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22582         if (_res_constr.datalen > 0)
22583                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
22584         else
22585                 _res_constr.data = NULL;
22586         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22587         for (size_t v = 0; v < _res_constr.datalen; v++) {
22588                 int64_t _res_conv_21 = _res_vals[v];
22589                 void* _res_conv_21_ptr = untag_ptr(_res_conv_21);
22590                 CHECK_ACCESS(_res_conv_21_ptr);
22591                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
22592                 FREE(untag_ptr(_res_conv_21));
22593                 _res_constr.data[v] = _res_conv_21_conv;
22594         }
22595         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22596         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
22597 }
22598
22599 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
22600         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22601         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
22602         return tag_ptr(ret_conv, true);
22603 }
22604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22605         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(arg);
22606         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
22607         return ret_conv;
22608 }
22609
22610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22611         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(orig);
22612         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22613         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
22614         return tag_ptr(ret_conv, true);
22615 }
22616
22617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
22618         LDKThirtyTwoBytes a_ref;
22619         CHECK((*env)->GetArrayLength(env, a) == 32);
22620         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22621         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
22622         b_constr.datalen = (*env)->GetArrayLength(env, b);
22623         if (b_constr.datalen > 0)
22624                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
22625         else
22626                 b_constr.data = NULL;
22627         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
22628         for (size_t v = 0; v < b_constr.datalen; v++) {
22629                 int64_t b_conv_21 = b_vals[v];
22630                 void* b_conv_21_ptr = untag_ptr(b_conv_21);
22631                 CHECK_ACCESS(b_conv_21_ptr);
22632                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
22633                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)untag_ptr(b_conv_21));
22634                 b_constr.data[v] = b_conv_21_conv;
22635         }
22636         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
22637         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22638         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
22639         return tag_ptr(ret_conv, true);
22640 }
22641
22642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22643         if (!ptr_is_owned(_res)) return;
22644         void* _res_ptr = untag_ptr(_res);
22645         CHECK_ACCESS(_res_ptr);
22646         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
22647         FREE(untag_ptr(_res));
22648         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
22649 }
22650
22651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22652         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
22653         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22654         if (_res_constr.datalen > 0)
22655                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
22656         else
22657                 _res_constr.data = NULL;
22658         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22659         for (size_t o = 0; o < _res_constr.datalen; o++) {
22660                 int64_t _res_conv_40 = _res_vals[o];
22661                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
22662                 CHECK_ACCESS(_res_conv_40_ptr);
22663                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
22664                 FREE(untag_ptr(_res_conv_40));
22665                 _res_constr.data[o] = _res_conv_40_conv;
22666         }
22667         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22668         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
22669 }
22670
22671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22672         LDKCVec_EventZ _res_constr;
22673         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22674         if (_res_constr.datalen > 0)
22675                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
22676         else
22677                 _res_constr.data = NULL;
22678         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22679         for (size_t h = 0; h < _res_constr.datalen; h++) {
22680                 int64_t _res_conv_7 = _res_vals[h];
22681                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
22682                 CHECK_ACCESS(_res_conv_7_ptr);
22683                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
22684                 FREE(untag_ptr(_res_conv_7));
22685                 _res_constr.data[h] = _res_conv_7_conv;
22686         }
22687         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22688         CVec_EventZ_free(_res_constr);
22689 }
22690
22691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
22692         LDKCVec_TransactionZ _res_constr;
22693         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22694         if (_res_constr.datalen > 0)
22695                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
22696         else
22697                 _res_constr.data = NULL;
22698         for (size_t i = 0; i < _res_constr.datalen; i++) {
22699                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
22700                 LDKTransaction _res_conv_8_ref;
22701                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
22702                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
22703                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
22704                 _res_conv_8_ref.data_is_owned = true;
22705                 _res_constr.data[i] = _res_conv_8_ref;
22706         }
22707         CVec_TransactionZ_free(_res_constr);
22708 }
22709
22710 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
22711         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22712         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
22713         return tag_ptr(ret_conv, true);
22714 }
22715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22716         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(arg);
22717         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
22718         return ret_conv;
22719 }
22720
22721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22722         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(orig);
22723         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22724         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
22725         return tag_ptr(ret_conv, true);
22726 }
22727
22728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
22729         void* b_ptr = untag_ptr(b);
22730         CHECK_ACCESS(b_ptr);
22731         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
22732         b_conv = TxOut_clone((LDKTxOut*)untag_ptr(b));
22733         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22734         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
22735         return tag_ptr(ret_conv, true);
22736 }
22737
22738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22739         if (!ptr_is_owned(_res)) return;
22740         void* _res_ptr = untag_ptr(_res);
22741         CHECK_ACCESS(_res_ptr);
22742         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
22743         FREE(untag_ptr(_res));
22744         C2Tuple_u32TxOutZ_free(_res_conv);
22745 }
22746
22747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22748         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
22749         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22750         if (_res_constr.datalen > 0)
22751                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22752         else
22753                 _res_constr.data = NULL;
22754         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22755         for (size_t u = 0; u < _res_constr.datalen; u++) {
22756                 int64_t _res_conv_20 = _res_vals[u];
22757                 void* _res_conv_20_ptr = untag_ptr(_res_conv_20);
22758                 CHECK_ACCESS(_res_conv_20_ptr);
22759                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
22760                 FREE(untag_ptr(_res_conv_20));
22761                 _res_constr.data[u] = _res_conv_20_conv;
22762         }
22763         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22764         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
22765 }
22766
22767 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
22768         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22769         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
22770         return tag_ptr(ret_conv, true);
22771 }
22772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22773         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(arg);
22774         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
22775         return ret_conv;
22776 }
22777
22778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22779         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(orig);
22780         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22781         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
22782         return tag_ptr(ret_conv, true);
22783 }
22784
22785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
22786         LDKThirtyTwoBytes a_ref;
22787         CHECK((*env)->GetArrayLength(env, a) == 32);
22788         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22789         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
22790         b_constr.datalen = (*env)->GetArrayLength(env, b);
22791         if (b_constr.datalen > 0)
22792                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22793         else
22794                 b_constr.data = NULL;
22795         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
22796         for (size_t u = 0; u < b_constr.datalen; u++) {
22797                 int64_t b_conv_20 = b_vals[u];
22798                 void* b_conv_20_ptr = untag_ptr(b_conv_20);
22799                 CHECK_ACCESS(b_conv_20_ptr);
22800                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
22801                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)untag_ptr(b_conv_20));
22802                 b_constr.data[u] = b_conv_20_conv;
22803         }
22804         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
22805         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22806         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
22807         return tag_ptr(ret_conv, true);
22808 }
22809
22810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22811         if (!ptr_is_owned(_res)) return;
22812         void* _res_ptr = untag_ptr(_res);
22813         CHECK_ACCESS(_res_ptr);
22814         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
22815         FREE(untag_ptr(_res));
22816         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
22817 }
22818
22819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22820         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
22821         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22822         if (_res_constr.datalen > 0)
22823                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
22824         else
22825                 _res_constr.data = NULL;
22826         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22827         for (size_t n = 0; n < _res_constr.datalen; n++) {
22828                 int64_t _res_conv_39 = _res_vals[n];
22829                 void* _res_conv_39_ptr = untag_ptr(_res_conv_39);
22830                 CHECK_ACCESS(_res_conv_39_ptr);
22831                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
22832                 FREE(untag_ptr(_res_conv_39));
22833                 _res_constr.data[n] = _res_conv_39_conv;
22834         }
22835         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22836         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
22837 }
22838
22839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22840         LDKCVec_BalanceZ _res_constr;
22841         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22842         if (_res_constr.datalen > 0)
22843                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
22844         else
22845                 _res_constr.data = NULL;
22846         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22847         for (size_t j = 0; j < _res_constr.datalen; j++) {
22848                 int64_t _res_conv_9 = _res_vals[j];
22849                 void* _res_conv_9_ptr = untag_ptr(_res_conv_9);
22850                 CHECK_ACCESS(_res_conv_9_ptr);
22851                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
22852                 FREE(untag_ptr(_res_conv_9));
22853                 _res_constr.data[j] = _res_conv_9_conv;
22854         }
22855         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22856         CVec_BalanceZ_free(_res_constr);
22857 }
22858
22859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22860         void* o_ptr = untag_ptr(o);
22861         CHECK_ACCESS(o_ptr);
22862         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
22863         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o));
22864         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22865         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
22866         return tag_ptr(ret_conv, true);
22867 }
22868
22869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22870         void* e_ptr = untag_ptr(e);
22871         CHECK_ACCESS(e_ptr);
22872         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22873         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22874         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22875         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
22876         return tag_ptr(ret_conv, true);
22877 }
22878
22879 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22880         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(o);
22881         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
22882         return ret_conv;
22883 }
22884
22885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22886         if (!ptr_is_owned(_res)) return;
22887         void* _res_ptr = untag_ptr(_res);
22888         CHECK_ACCESS(_res_ptr);
22889         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
22890         FREE(untag_ptr(_res));
22891         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
22892 }
22893
22894 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
22895         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22896         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
22897         return tag_ptr(ret_conv, true);
22898 }
22899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22900         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(arg);
22901         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
22902         return ret_conv;
22903 }
22904
22905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22906         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(orig);
22907         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22908         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
22909         return tag_ptr(ret_conv, true);
22910 }
22911
22912 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
22913         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22914         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
22915         return tag_ptr(ret_conv, true);
22916 }
22917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22918         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(arg);
22919         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
22920         return ret_conv;
22921 }
22922
22923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22924         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(orig);
22925         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22926         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
22927         return tag_ptr(ret_conv, true);
22928 }
22929
22930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
22931         LDKPublicKey a_ref;
22932         CHECK((*env)->GetArrayLength(env, a) == 33);
22933         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
22934         void* b_ptr = untag_ptr(b);
22935         CHECK_ACCESS(b_ptr);
22936         LDKType b_conv = *(LDKType*)(b_ptr);
22937         if (b_conv.free == LDKType_JCalls_free) {
22938                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22939                 LDKType_JCalls_cloned(&b_conv);
22940         }
22941         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22942         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
22943         return tag_ptr(ret_conv, true);
22944 }
22945
22946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22947         if (!ptr_is_owned(_res)) return;
22948         void* _res_ptr = untag_ptr(_res);
22949         CHECK_ACCESS(_res_ptr);
22950         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
22951         FREE(untag_ptr(_res));
22952         C2Tuple_PublicKeyTypeZ_free(_res_conv);
22953 }
22954
22955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22956         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
22957         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22958         if (_res_constr.datalen > 0)
22959                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
22960         else
22961                 _res_constr.data = NULL;
22962         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22963         for (size_t z = 0; z < _res_constr.datalen; z++) {
22964                 int64_t _res_conv_25 = _res_vals[z];
22965                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
22966                 CHECK_ACCESS(_res_conv_25_ptr);
22967                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
22968                 FREE(untag_ptr(_res_conv_25));
22969                 _res_constr.data[z] = _res_conv_25_conv;
22970         }
22971         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22972         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
22973 }
22974
22975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22976         void* o_ptr = untag_ptr(o);
22977         CHECK_ACCESS(o_ptr);
22978         LDKCustomOnionMessageContents o_conv = *(LDKCustomOnionMessageContents*)(o_ptr);
22979         if (o_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
22980                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22981                 LDKCustomOnionMessageContents_JCalls_cloned(&o_conv);
22982         }
22983         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22984         *ret_copy = COption_CustomOnionMessageContentsZ_some(o_conv);
22985         int64_t ret_ref = tag_ptr(ret_copy, true);
22986         return ret_ref;
22987 }
22988
22989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1none(JNIEnv *env, jclass clz) {
22990         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22991         *ret_copy = COption_CustomOnionMessageContentsZ_none();
22992         int64_t ret_ref = tag_ptr(ret_copy, true);
22993         return ret_ref;
22994 }
22995
22996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22997         if (!ptr_is_owned(_res)) return;
22998         void* _res_ptr = untag_ptr(_res);
22999         CHECK_ACCESS(_res_ptr);
23000         LDKCOption_CustomOnionMessageContentsZ _res_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(_res_ptr);
23001         FREE(untag_ptr(_res));
23002         COption_CustomOnionMessageContentsZ_free(_res_conv);
23003 }
23004
23005 static inline uint64_t COption_CustomOnionMessageContentsZ_clone_ptr(LDKCOption_CustomOnionMessageContentsZ *NONNULL_PTR arg) {
23006         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23007         *ret_copy = COption_CustomOnionMessageContentsZ_clone(arg);
23008         int64_t ret_ref = tag_ptr(ret_copy, true);
23009         return ret_ref;
23010 }
23011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23012         LDKCOption_CustomOnionMessageContentsZ* arg_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(arg);
23013         int64_t ret_conv = COption_CustomOnionMessageContentsZ_clone_ptr(arg_conv);
23014         return ret_conv;
23015 }
23016
23017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23018         LDKCOption_CustomOnionMessageContentsZ* orig_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(orig);
23019         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23020         *ret_copy = COption_CustomOnionMessageContentsZ_clone(orig_conv);
23021         int64_t ret_ref = tag_ptr(ret_copy, true);
23022         return ret_ref;
23023 }
23024
23025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23026         void* o_ptr = untag_ptr(o);
23027         CHECK_ACCESS(o_ptr);
23028         LDKCOption_CustomOnionMessageContentsZ o_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(o_ptr);
23029         o_conv = COption_CustomOnionMessageContentsZ_clone((LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(o));
23030         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23031         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(o_conv);
23032         return tag_ptr(ret_conv, true);
23033 }
23034
23035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23036         void* e_ptr = untag_ptr(e);
23037         CHECK_ACCESS(e_ptr);
23038         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23039         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23040         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23041         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(e_conv);
23042         return tag_ptr(ret_conv, true);
23043 }
23044
23045 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23046         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* o_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(o);
23047         jboolean ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(o_conv);
23048         return ret_conv;
23049 }
23050
23051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23052         if (!ptr_is_owned(_res)) return;
23053         void* _res_ptr = untag_ptr(_res);
23054         CHECK_ACCESS(_res_ptr);
23055         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ _res_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(_res_ptr);
23056         FREE(untag_ptr(_res));
23057         CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(_res_conv);
23058 }
23059
23060 static inline uint64_t CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR arg) {
23061         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23062         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(arg);
23063         return tag_ptr(ret_conv, true);
23064 }
23065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23066         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* arg_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(arg);
23067         int64_t ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(arg_conv);
23068         return ret_conv;
23069 }
23070
23071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23072         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* orig_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(orig);
23073         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23074         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(orig_conv);
23075         return tag_ptr(ret_conv, true);
23076 }
23077
23078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23079         void* o_ptr = untag_ptr(o);
23080         CHECK_ACCESS(o_ptr);
23081         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
23082         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
23083         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23084         *ret_copy = COption_NetAddressZ_some(o_conv);
23085         int64_t ret_ref = tag_ptr(ret_copy, true);
23086         return ret_ref;
23087 }
23088
23089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
23090         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23091         *ret_copy = COption_NetAddressZ_none();
23092         int64_t ret_ref = tag_ptr(ret_copy, true);
23093         return ret_ref;
23094 }
23095
23096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23097         if (!ptr_is_owned(_res)) return;
23098         void* _res_ptr = untag_ptr(_res);
23099         CHECK_ACCESS(_res_ptr);
23100         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
23101         FREE(untag_ptr(_res));
23102         COption_NetAddressZ_free(_res_conv);
23103 }
23104
23105 static inline uint64_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
23106         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23107         *ret_copy = COption_NetAddressZ_clone(arg);
23108         int64_t ret_ref = tag_ptr(ret_copy, true);
23109         return ret_ref;
23110 }
23111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23112         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)untag_ptr(arg);
23113         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
23114         return ret_conv;
23115 }
23116
23117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23118         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)untag_ptr(orig);
23119         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23120         *ret_copy = COption_NetAddressZ_clone(orig_conv);
23121         int64_t ret_ref = tag_ptr(ret_copy, true);
23122         return ret_ref;
23123 }
23124
23125 static inline uint64_t C2Tuple_PublicKeyCOption_NetAddressZZ_clone_ptr(LDKC2Tuple_PublicKeyCOption_NetAddressZZ *NONNULL_PTR arg) {
23126         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
23127         *ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_clone(arg);
23128         return tag_ptr(ret_conv, true);
23129 }
23130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23131         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* arg_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(arg);
23132         int64_t ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_clone_ptr(arg_conv);
23133         return ret_conv;
23134 }
23135
23136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23137         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* orig_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(orig);
23138         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
23139         *ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_clone(orig_conv);
23140         return tag_ptr(ret_conv, true);
23141 }
23142
23143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
23144         LDKPublicKey a_ref;
23145         CHECK((*env)->GetArrayLength(env, a) == 33);
23146         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
23147         void* b_ptr = untag_ptr(b);
23148         CHECK_ACCESS(b_ptr);
23149         LDKCOption_NetAddressZ b_conv = *(LDKCOption_NetAddressZ*)(b_ptr);
23150         b_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(b));
23151         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
23152         *ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_new(a_ref, b_conv);
23153         return tag_ptr(ret_conv, true);
23154 }
23155
23156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23157         if (!ptr_is_owned(_res)) return;
23158         void* _res_ptr = untag_ptr(_res);
23159         CHECK_ACCESS(_res_ptr);
23160         LDKC2Tuple_PublicKeyCOption_NetAddressZZ _res_conv = *(LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)(_res_ptr);
23161         FREE(untag_ptr(_res));
23162         C2Tuple_PublicKeyCOption_NetAddressZZ_free(_res_conv);
23163 }
23164
23165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyCOption_1NetAddressZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23166         LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ _res_constr;
23167         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23168         if (_res_constr.datalen > 0)
23169                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ Elements");
23170         else
23171                 _res_constr.data = NULL;
23172         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23173         for (size_t o = 0; o < _res_constr.datalen; o++) {
23174                 int64_t _res_conv_40 = _res_vals[o];
23175                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
23176                 CHECK_ACCESS(_res_conv_40_ptr);
23177                 LDKC2Tuple_PublicKeyCOption_NetAddressZZ _res_conv_40_conv = *(LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)(_res_conv_40_ptr);
23178                 FREE(untag_ptr(_res_conv_40));
23179                 _res_constr.data[o] = _res_conv_40_conv;
23180         }
23181         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23182         CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_free(_res_constr);
23183 }
23184
23185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
23186         LDKCVec_u8Z o_ref;
23187         o_ref.datalen = (*env)->GetArrayLength(env, o);
23188         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
23189         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
23190         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23191         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
23192         return tag_ptr(ret_conv, true);
23193 }
23194
23195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23196         LDKPeerHandleError e_conv;
23197         e_conv.inner = untag_ptr(e);
23198         e_conv.is_owned = ptr_is_owned(e);
23199         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23200         e_conv = PeerHandleError_clone(&e_conv);
23201         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23202         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
23203         return tag_ptr(ret_conv, true);
23204 }
23205
23206 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23207         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(o);
23208         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
23209         return ret_conv;
23210 }
23211
23212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23213         if (!ptr_is_owned(_res)) return;
23214         void* _res_ptr = untag_ptr(_res);
23215         CHECK_ACCESS(_res_ptr);
23216         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
23217         FREE(untag_ptr(_res));
23218         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
23219 }
23220
23221 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
23222         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23223         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
23224         return tag_ptr(ret_conv, true);
23225 }
23226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23227         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(arg);
23228         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
23229         return ret_conv;
23230 }
23231
23232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23233         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(orig);
23234         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23235         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
23236         return tag_ptr(ret_conv, true);
23237 }
23238
23239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
23240         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23241         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
23242         return tag_ptr(ret_conv, true);
23243 }
23244
23245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23246         LDKPeerHandleError e_conv;
23247         e_conv.inner = untag_ptr(e);
23248         e_conv.is_owned = ptr_is_owned(e);
23249         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23250         e_conv = PeerHandleError_clone(&e_conv);
23251         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23252         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
23253         return tag_ptr(ret_conv, true);
23254 }
23255
23256 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23257         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(o);
23258         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
23259         return ret_conv;
23260 }
23261
23262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23263         if (!ptr_is_owned(_res)) return;
23264         void* _res_ptr = untag_ptr(_res);
23265         CHECK_ACCESS(_res_ptr);
23266         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
23267         FREE(untag_ptr(_res));
23268         CResult_NonePeerHandleErrorZ_free(_res_conv);
23269 }
23270
23271 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
23272         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23273         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
23274         return tag_ptr(ret_conv, true);
23275 }
23276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23277         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(arg);
23278         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
23279         return ret_conv;
23280 }
23281
23282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23283         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(orig);
23284         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23285         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
23286         return tag_ptr(ret_conv, true);
23287 }
23288
23289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
23290         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23291         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
23292         return tag_ptr(ret_conv, true);
23293 }
23294
23295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23296         LDKPeerHandleError e_conv;
23297         e_conv.inner = untag_ptr(e);
23298         e_conv.is_owned = ptr_is_owned(e);
23299         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23300         e_conv = PeerHandleError_clone(&e_conv);
23301         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23302         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
23303         return tag_ptr(ret_conv, true);
23304 }
23305
23306 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23307         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(o);
23308         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
23309         return ret_conv;
23310 }
23311
23312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23313         if (!ptr_is_owned(_res)) return;
23314         void* _res_ptr = untag_ptr(_res);
23315         CHECK_ACCESS(_res_ptr);
23316         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
23317         FREE(untag_ptr(_res));
23318         CResult_boolPeerHandleErrorZ_free(_res_conv);
23319 }
23320
23321 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
23322         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23323         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
23324         return tag_ptr(ret_conv, true);
23325 }
23326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23327         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(arg);
23328         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
23329         return ret_conv;
23330 }
23331
23332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23333         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(orig);
23334         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23335         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
23336         return tag_ptr(ret_conv, true);
23337 }
23338
23339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23340         void* o_ptr = untag_ptr(o);
23341         CHECK_ACCESS(o_ptr);
23342         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
23343         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
23344         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
23345         *ret_conv = CResult_TxOutUtxoLookupErrorZ_ok(o_conv);
23346         return tag_ptr(ret_conv, true);
23347 }
23348
23349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23350         LDKUtxoLookupError e_conv = LDKUtxoLookupError_from_java(env, e);
23351         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
23352         *ret_conv = CResult_TxOutUtxoLookupErrorZ_err(e_conv);
23353         return tag_ptr(ret_conv, true);
23354 }
23355
23356 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23357         LDKCResult_TxOutUtxoLookupErrorZ* o_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(o);
23358         jboolean ret_conv = CResult_TxOutUtxoLookupErrorZ_is_ok(o_conv);
23359         return ret_conv;
23360 }
23361
23362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23363         if (!ptr_is_owned(_res)) return;
23364         void* _res_ptr = untag_ptr(_res);
23365         CHECK_ACCESS(_res_ptr);
23366         LDKCResult_TxOutUtxoLookupErrorZ _res_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(_res_ptr);
23367         FREE(untag_ptr(_res));
23368         CResult_TxOutUtxoLookupErrorZ_free(_res_conv);
23369 }
23370
23371 static inline uint64_t CResult_TxOutUtxoLookupErrorZ_clone_ptr(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR arg) {
23372         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
23373         *ret_conv = CResult_TxOutUtxoLookupErrorZ_clone(arg);
23374         return tag_ptr(ret_conv, true);
23375 }
23376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23377         LDKCResult_TxOutUtxoLookupErrorZ* arg_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(arg);
23378         int64_t ret_conv = CResult_TxOutUtxoLookupErrorZ_clone_ptr(arg_conv);
23379         return ret_conv;
23380 }
23381
23382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23383         LDKCResult_TxOutUtxoLookupErrorZ* orig_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(orig);
23384         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
23385         *ret_conv = CResult_TxOutUtxoLookupErrorZ_clone(orig_conv);
23386         return tag_ptr(ret_conv, true);
23387 }
23388
23389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1ok(JNIEnv *env, jclass clz) {
23390         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
23391         *ret_conv = CResult_NoneSendErrorZ_ok();
23392         return tag_ptr(ret_conv, true);
23393 }
23394
23395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23396         void* e_ptr = untag_ptr(e);
23397         CHECK_ACCESS(e_ptr);
23398         LDKSendError e_conv = *(LDKSendError*)(e_ptr);
23399         e_conv = SendError_clone((LDKSendError*)untag_ptr(e));
23400         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
23401         *ret_conv = CResult_NoneSendErrorZ_err(e_conv);
23402         return tag_ptr(ret_conv, true);
23403 }
23404
23405 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23406         LDKCResult_NoneSendErrorZ* o_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(o);
23407         jboolean ret_conv = CResult_NoneSendErrorZ_is_ok(o_conv);
23408         return ret_conv;
23409 }
23410
23411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23412         if (!ptr_is_owned(_res)) return;
23413         void* _res_ptr = untag_ptr(_res);
23414         CHECK_ACCESS(_res_ptr);
23415         LDKCResult_NoneSendErrorZ _res_conv = *(LDKCResult_NoneSendErrorZ*)(_res_ptr);
23416         FREE(untag_ptr(_res));
23417         CResult_NoneSendErrorZ_free(_res_conv);
23418 }
23419
23420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
23421         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
23422         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
23423         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
23424         return tag_ptr(ret_conv, true);
23425 }
23426
23427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23428         void* e_ptr = untag_ptr(e);
23429         CHECK_ACCESS(e_ptr);
23430         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
23431         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
23432         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
23433         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
23434         return tag_ptr(ret_conv, true);
23435 }
23436
23437 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23438         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(o);
23439         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
23440         return ret_conv;
23441 }
23442
23443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23444         if (!ptr_is_owned(_res)) return;
23445         void* _res_ptr = untag_ptr(_res);
23446         CHECK_ACCESS(_res_ptr);
23447         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
23448         FREE(untag_ptr(_res));
23449         CResult_SiPrefixParseErrorZ_free(_res_conv);
23450 }
23451
23452 static inline uint64_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
23453         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
23454         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
23455         return tag_ptr(ret_conv, true);
23456 }
23457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23458         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(arg);
23459         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
23460         return ret_conv;
23461 }
23462
23463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23464         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(orig);
23465         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
23466         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
23467         return tag_ptr(ret_conv, true);
23468 }
23469
23470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23471         LDKInvoice o_conv;
23472         o_conv.inner = untag_ptr(o);
23473         o_conv.is_owned = ptr_is_owned(o);
23474         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23475         o_conv = Invoice_clone(&o_conv);
23476         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
23477         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
23478         return tag_ptr(ret_conv, true);
23479 }
23480
23481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23482         void* e_ptr = untag_ptr(e);
23483         CHECK_ACCESS(e_ptr);
23484         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
23485         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)untag_ptr(e));
23486         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
23487         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
23488         return tag_ptr(ret_conv, true);
23489 }
23490
23491 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23492         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(o);
23493         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
23494         return ret_conv;
23495 }
23496
23497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23498         if (!ptr_is_owned(_res)) return;
23499         void* _res_ptr = untag_ptr(_res);
23500         CHECK_ACCESS(_res_ptr);
23501         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
23502         FREE(untag_ptr(_res));
23503         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
23504 }
23505
23506 static inline uint64_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
23507         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
23508         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
23509         return tag_ptr(ret_conv, true);
23510 }
23511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23512         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(arg);
23513         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
23514         return ret_conv;
23515 }
23516
23517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23518         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(orig);
23519         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
23520         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
23521         return tag_ptr(ret_conv, true);
23522 }
23523
23524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23525         LDKSignedRawInvoice o_conv;
23526         o_conv.inner = untag_ptr(o);
23527         o_conv.is_owned = ptr_is_owned(o);
23528         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23529         o_conv = SignedRawInvoice_clone(&o_conv);
23530         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
23531         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
23532         return tag_ptr(ret_conv, true);
23533 }
23534
23535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23536         void* e_ptr = untag_ptr(e);
23537         CHECK_ACCESS(e_ptr);
23538         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
23539         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
23540         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
23541         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
23542         return tag_ptr(ret_conv, true);
23543 }
23544
23545 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23546         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(o);
23547         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
23548         return ret_conv;
23549 }
23550
23551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23552         if (!ptr_is_owned(_res)) return;
23553         void* _res_ptr = untag_ptr(_res);
23554         CHECK_ACCESS(_res_ptr);
23555         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
23556         FREE(untag_ptr(_res));
23557         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
23558 }
23559
23560 static inline uint64_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
23561         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
23562         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
23563         return tag_ptr(ret_conv, true);
23564 }
23565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23566         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(arg);
23567         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
23568         return ret_conv;
23569 }
23570
23571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23572         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(orig);
23573         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
23574         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
23575         return tag_ptr(ret_conv, true);
23576 }
23577
23578 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
23579         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
23580         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
23581         return tag_ptr(ret_conv, true);
23582 }
23583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23584         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(arg);
23585         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
23586         return ret_conv;
23587 }
23588
23589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23590         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(orig);
23591         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
23592         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
23593         return tag_ptr(ret_conv, true);
23594 }
23595
23596 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) {
23597         LDKRawInvoice a_conv;
23598         a_conv.inner = untag_ptr(a);
23599         a_conv.is_owned = ptr_is_owned(a);
23600         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23601         a_conv = RawInvoice_clone(&a_conv);
23602         LDKThirtyTwoBytes b_ref;
23603         CHECK((*env)->GetArrayLength(env, b) == 32);
23604         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
23605         LDKInvoiceSignature c_conv;
23606         c_conv.inner = untag_ptr(c);
23607         c_conv.is_owned = ptr_is_owned(c);
23608         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
23609         c_conv = InvoiceSignature_clone(&c_conv);
23610         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
23611         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
23612         return tag_ptr(ret_conv, true);
23613 }
23614
23615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23616         if (!ptr_is_owned(_res)) return;
23617         void* _res_ptr = untag_ptr(_res);
23618         CHECK_ACCESS(_res_ptr);
23619         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
23620         FREE(untag_ptr(_res));
23621         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
23622 }
23623
23624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23625         LDKPayeePubKey o_conv;
23626         o_conv.inner = untag_ptr(o);
23627         o_conv.is_owned = ptr_is_owned(o);
23628         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23629         o_conv = PayeePubKey_clone(&o_conv);
23630         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
23631         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
23632         return tag_ptr(ret_conv, true);
23633 }
23634
23635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23636         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
23637         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
23638         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
23639         return tag_ptr(ret_conv, true);
23640 }
23641
23642 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23643         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(o);
23644         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
23645         return ret_conv;
23646 }
23647
23648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23649         if (!ptr_is_owned(_res)) return;
23650         void* _res_ptr = untag_ptr(_res);
23651         CHECK_ACCESS(_res_ptr);
23652         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
23653         FREE(untag_ptr(_res));
23654         CResult_PayeePubKeyErrorZ_free(_res_conv);
23655 }
23656
23657 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
23658         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
23659         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
23660         return tag_ptr(ret_conv, true);
23661 }
23662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23663         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(arg);
23664         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
23665         return ret_conv;
23666 }
23667
23668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23669         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(orig);
23670         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
23671         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
23672         return tag_ptr(ret_conv, true);
23673 }
23674
23675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23676         LDKCVec_PrivateRouteZ _res_constr;
23677         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23678         if (_res_constr.datalen > 0)
23679                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
23680         else
23681                 _res_constr.data = NULL;
23682         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23683         for (size_t o = 0; o < _res_constr.datalen; o++) {
23684                 int64_t _res_conv_14 = _res_vals[o];
23685                 LDKPrivateRoute _res_conv_14_conv;
23686                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
23687                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
23688                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
23689                 _res_constr.data[o] = _res_conv_14_conv;
23690         }
23691         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23692         CVec_PrivateRouteZ_free(_res_constr);
23693 }
23694
23695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23696         LDKPositiveTimestamp o_conv;
23697         o_conv.inner = untag_ptr(o);
23698         o_conv.is_owned = ptr_is_owned(o);
23699         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23700         o_conv = PositiveTimestamp_clone(&o_conv);
23701         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
23702         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
23703         return tag_ptr(ret_conv, true);
23704 }
23705
23706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23707         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
23708         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
23709         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
23710         return tag_ptr(ret_conv, true);
23711 }
23712
23713 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23714         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(o);
23715         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
23716         return ret_conv;
23717 }
23718
23719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23720         if (!ptr_is_owned(_res)) return;
23721         void* _res_ptr = untag_ptr(_res);
23722         CHECK_ACCESS(_res_ptr);
23723         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
23724         FREE(untag_ptr(_res));
23725         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
23726 }
23727
23728 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
23729         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
23730         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
23731         return tag_ptr(ret_conv, true);
23732 }
23733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23734         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(arg);
23735         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
23736         return ret_conv;
23737 }
23738
23739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23740         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(orig);
23741         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
23742         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
23743         return tag_ptr(ret_conv, true);
23744 }
23745
23746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
23747         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
23748         *ret_conv = CResult_NoneSemanticErrorZ_ok();
23749         return tag_ptr(ret_conv, true);
23750 }
23751
23752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23753         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
23754         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
23755         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
23756         return tag_ptr(ret_conv, true);
23757 }
23758
23759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23760         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(o);
23761         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
23762         return ret_conv;
23763 }
23764
23765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23766         if (!ptr_is_owned(_res)) return;
23767         void* _res_ptr = untag_ptr(_res);
23768         CHECK_ACCESS(_res_ptr);
23769         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
23770         FREE(untag_ptr(_res));
23771         CResult_NoneSemanticErrorZ_free(_res_conv);
23772 }
23773
23774 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
23775         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
23776         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
23777         return tag_ptr(ret_conv, true);
23778 }
23779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23780         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(arg);
23781         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
23782         return ret_conv;
23783 }
23784
23785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23786         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(orig);
23787         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
23788         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
23789         return tag_ptr(ret_conv, true);
23790 }
23791
23792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23793         LDKInvoice o_conv;
23794         o_conv.inner = untag_ptr(o);
23795         o_conv.is_owned = ptr_is_owned(o);
23796         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23797         o_conv = Invoice_clone(&o_conv);
23798         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
23799         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
23800         return tag_ptr(ret_conv, true);
23801 }
23802
23803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23804         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
23805         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
23806         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
23807         return tag_ptr(ret_conv, true);
23808 }
23809
23810 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23811         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(o);
23812         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
23813         return ret_conv;
23814 }
23815
23816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23817         if (!ptr_is_owned(_res)) return;
23818         void* _res_ptr = untag_ptr(_res);
23819         CHECK_ACCESS(_res_ptr);
23820         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
23821         FREE(untag_ptr(_res));
23822         CResult_InvoiceSemanticErrorZ_free(_res_conv);
23823 }
23824
23825 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
23826         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
23827         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
23828         return tag_ptr(ret_conv, true);
23829 }
23830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23831         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(arg);
23832         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
23833         return ret_conv;
23834 }
23835
23836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23837         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(orig);
23838         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
23839         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
23840         return tag_ptr(ret_conv, true);
23841 }
23842
23843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23844         LDKDescription o_conv;
23845         o_conv.inner = untag_ptr(o);
23846         o_conv.is_owned = ptr_is_owned(o);
23847         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23848         o_conv = Description_clone(&o_conv);
23849         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
23850         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
23851         return tag_ptr(ret_conv, true);
23852 }
23853
23854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23855         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
23856         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
23857         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
23858         return tag_ptr(ret_conv, true);
23859 }
23860
23861 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23862         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(o);
23863         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
23864         return ret_conv;
23865 }
23866
23867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23868         if (!ptr_is_owned(_res)) return;
23869         void* _res_ptr = untag_ptr(_res);
23870         CHECK_ACCESS(_res_ptr);
23871         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
23872         FREE(untag_ptr(_res));
23873         CResult_DescriptionCreationErrorZ_free(_res_conv);
23874 }
23875
23876 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
23877         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
23878         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
23879         return tag_ptr(ret_conv, true);
23880 }
23881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23882         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(arg);
23883         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
23884         return ret_conv;
23885 }
23886
23887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23888         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(orig);
23889         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
23890         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
23891         return tag_ptr(ret_conv, true);
23892 }
23893
23894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23895         LDKPrivateRoute o_conv;
23896         o_conv.inner = untag_ptr(o);
23897         o_conv.is_owned = ptr_is_owned(o);
23898         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23899         o_conv = PrivateRoute_clone(&o_conv);
23900         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
23901         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
23902         return tag_ptr(ret_conv, true);
23903 }
23904
23905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23906         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
23907         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
23908         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
23909         return tag_ptr(ret_conv, true);
23910 }
23911
23912 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23913         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(o);
23914         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
23915         return ret_conv;
23916 }
23917
23918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23919         if (!ptr_is_owned(_res)) return;
23920         void* _res_ptr = untag_ptr(_res);
23921         CHECK_ACCESS(_res_ptr);
23922         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
23923         FREE(untag_ptr(_res));
23924         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
23925 }
23926
23927 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
23928         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
23929         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
23930         return tag_ptr(ret_conv, true);
23931 }
23932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23933         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(arg);
23934         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
23935         return ret_conv;
23936 }
23937
23938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23939         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(orig);
23940         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
23941         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
23942         return tag_ptr(ret_conv, true);
23943 }
23944
23945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
23946         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
23947         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
23948         return tag_ptr(ret_conv, true);
23949 }
23950
23951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23952         void* e_ptr = untag_ptr(e);
23953         CHECK_ACCESS(e_ptr);
23954         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
23955         e_conv = GraphSyncError_clone((LDKGraphSyncError*)untag_ptr(e));
23956         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
23957         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
23958         return tag_ptr(ret_conv, true);
23959 }
23960
23961 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23962         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(o);
23963         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
23964         return ret_conv;
23965 }
23966
23967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23968         if (!ptr_is_owned(_res)) return;
23969         void* _res_ptr = untag_ptr(_res);
23970         CHECK_ACCESS(_res_ptr);
23971         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
23972         FREE(untag_ptr(_res));
23973         CResult_u32GraphSyncErrorZ_free(_res_conv);
23974 }
23975
23976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23977         void* o_ptr = untag_ptr(o);
23978         CHECK_ACCESS(o_ptr);
23979         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
23980         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
23981         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23982         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
23983         return tag_ptr(ret_conv, true);
23984 }
23985
23986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23987         void* e_ptr = untag_ptr(e);
23988         CHECK_ACCESS(e_ptr);
23989         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23990         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23991         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23992         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
23993         return tag_ptr(ret_conv, true);
23994 }
23995
23996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23997         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(o);
23998         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
23999         return ret_conv;
24000 }
24001
24002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24003         if (!ptr_is_owned(_res)) return;
24004         void* _res_ptr = untag_ptr(_res);
24005         CHECK_ACCESS(_res_ptr);
24006         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
24007         FREE(untag_ptr(_res));
24008         CResult_NetAddressDecodeErrorZ_free(_res_conv);
24009 }
24010
24011 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
24012         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24013         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
24014         return tag_ptr(ret_conv, true);
24015 }
24016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24017         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(arg);
24018         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
24019         return ret_conv;
24020 }
24021
24022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24023         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(orig);
24024         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24025         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
24026         return tag_ptr(ret_conv, true);
24027 }
24028
24029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24030         LDKCVec_UpdateAddHTLCZ _res_constr;
24031         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24032         if (_res_constr.datalen > 0)
24033                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
24034         else
24035                 _res_constr.data = NULL;
24036         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24037         for (size_t p = 0; p < _res_constr.datalen; p++) {
24038                 int64_t _res_conv_15 = _res_vals[p];
24039                 LDKUpdateAddHTLC _res_conv_15_conv;
24040                 _res_conv_15_conv.inner = untag_ptr(_res_conv_15);
24041                 _res_conv_15_conv.is_owned = ptr_is_owned(_res_conv_15);
24042                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
24043                 _res_constr.data[p] = _res_conv_15_conv;
24044         }
24045         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24046         CVec_UpdateAddHTLCZ_free(_res_constr);
24047 }
24048
24049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24050         LDKCVec_UpdateFulfillHTLCZ _res_constr;
24051         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24052         if (_res_constr.datalen > 0)
24053                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
24054         else
24055                 _res_constr.data = NULL;
24056         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24057         for (size_t t = 0; t < _res_constr.datalen; t++) {
24058                 int64_t _res_conv_19 = _res_vals[t];
24059                 LDKUpdateFulfillHTLC _res_conv_19_conv;
24060                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
24061                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
24062                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
24063                 _res_constr.data[t] = _res_conv_19_conv;
24064         }
24065         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24066         CVec_UpdateFulfillHTLCZ_free(_res_constr);
24067 }
24068
24069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24070         LDKCVec_UpdateFailHTLCZ _res_constr;
24071         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24072         if (_res_constr.datalen > 0)
24073                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
24074         else
24075                 _res_constr.data = NULL;
24076         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24077         for (size_t q = 0; q < _res_constr.datalen; q++) {
24078                 int64_t _res_conv_16 = _res_vals[q];
24079                 LDKUpdateFailHTLC _res_conv_16_conv;
24080                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
24081                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
24082                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
24083                 _res_constr.data[q] = _res_conv_16_conv;
24084         }
24085         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24086         CVec_UpdateFailHTLCZ_free(_res_constr);
24087 }
24088
24089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24090         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
24091         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24092         if (_res_constr.datalen > 0)
24093                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
24094         else
24095                 _res_constr.data = NULL;
24096         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24097         for (size_t z = 0; z < _res_constr.datalen; z++) {
24098                 int64_t _res_conv_25 = _res_vals[z];
24099                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
24100                 _res_conv_25_conv.inner = untag_ptr(_res_conv_25);
24101                 _res_conv_25_conv.is_owned = ptr_is_owned(_res_conv_25);
24102                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
24103                 _res_constr.data[z] = _res_conv_25_conv;
24104         }
24105         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24106         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
24107 }
24108
24109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24110         LDKAcceptChannel o_conv;
24111         o_conv.inner = untag_ptr(o);
24112         o_conv.is_owned = ptr_is_owned(o);
24113         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24114         o_conv = AcceptChannel_clone(&o_conv);
24115         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24116         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
24117         return tag_ptr(ret_conv, true);
24118 }
24119
24120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24121         void* e_ptr = untag_ptr(e);
24122         CHECK_ACCESS(e_ptr);
24123         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24124         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24125         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24126         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
24127         return tag_ptr(ret_conv, true);
24128 }
24129
24130 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24131         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(o);
24132         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
24133         return ret_conv;
24134 }
24135
24136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24137         if (!ptr_is_owned(_res)) return;
24138         void* _res_ptr = untag_ptr(_res);
24139         CHECK_ACCESS(_res_ptr);
24140         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
24141         FREE(untag_ptr(_res));
24142         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
24143 }
24144
24145 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
24146         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24147         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
24148         return tag_ptr(ret_conv, true);
24149 }
24150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24151         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(arg);
24152         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
24153         return ret_conv;
24154 }
24155
24156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24157         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(orig);
24158         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24159         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
24160         return tag_ptr(ret_conv, true);
24161 }
24162
24163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24164         LDKAnnouncementSignatures o_conv;
24165         o_conv.inner = untag_ptr(o);
24166         o_conv.is_owned = ptr_is_owned(o);
24167         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24168         o_conv = AnnouncementSignatures_clone(&o_conv);
24169         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24170         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
24171         return tag_ptr(ret_conv, true);
24172 }
24173
24174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24175         void* e_ptr = untag_ptr(e);
24176         CHECK_ACCESS(e_ptr);
24177         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24178         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24179         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24180         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
24181         return tag_ptr(ret_conv, true);
24182 }
24183
24184 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24185         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(o);
24186         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
24187         return ret_conv;
24188 }
24189
24190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24191         if (!ptr_is_owned(_res)) return;
24192         void* _res_ptr = untag_ptr(_res);
24193         CHECK_ACCESS(_res_ptr);
24194         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
24195         FREE(untag_ptr(_res));
24196         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
24197 }
24198
24199 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
24200         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24201         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
24202         return tag_ptr(ret_conv, true);
24203 }
24204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24205         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(arg);
24206         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
24207         return ret_conv;
24208 }
24209
24210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24211         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(orig);
24212         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24213         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
24214         return tag_ptr(ret_conv, true);
24215 }
24216
24217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24218         LDKChannelReestablish o_conv;
24219         o_conv.inner = untag_ptr(o);
24220         o_conv.is_owned = ptr_is_owned(o);
24221         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24222         o_conv = ChannelReestablish_clone(&o_conv);
24223         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24224         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
24225         return tag_ptr(ret_conv, true);
24226 }
24227
24228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24229         void* e_ptr = untag_ptr(e);
24230         CHECK_ACCESS(e_ptr);
24231         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24232         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24233         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24234         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
24235         return tag_ptr(ret_conv, true);
24236 }
24237
24238 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24239         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(o);
24240         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
24241         return ret_conv;
24242 }
24243
24244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24245         if (!ptr_is_owned(_res)) return;
24246         void* _res_ptr = untag_ptr(_res);
24247         CHECK_ACCESS(_res_ptr);
24248         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
24249         FREE(untag_ptr(_res));
24250         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
24251 }
24252
24253 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
24254         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24255         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
24256         return tag_ptr(ret_conv, true);
24257 }
24258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24259         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(arg);
24260         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
24261         return ret_conv;
24262 }
24263
24264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24265         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(orig);
24266         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24267         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
24268         return tag_ptr(ret_conv, true);
24269 }
24270
24271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24272         LDKClosingSigned o_conv;
24273         o_conv.inner = untag_ptr(o);
24274         o_conv.is_owned = ptr_is_owned(o);
24275         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24276         o_conv = ClosingSigned_clone(&o_conv);
24277         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24278         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
24279         return tag_ptr(ret_conv, true);
24280 }
24281
24282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24283         void* e_ptr = untag_ptr(e);
24284         CHECK_ACCESS(e_ptr);
24285         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24286         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24287         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24288         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
24289         return tag_ptr(ret_conv, true);
24290 }
24291
24292 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24293         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(o);
24294         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
24295         return ret_conv;
24296 }
24297
24298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24299         if (!ptr_is_owned(_res)) return;
24300         void* _res_ptr = untag_ptr(_res);
24301         CHECK_ACCESS(_res_ptr);
24302         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
24303         FREE(untag_ptr(_res));
24304         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
24305 }
24306
24307 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
24308         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24309         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
24310         return tag_ptr(ret_conv, true);
24311 }
24312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24313         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(arg);
24314         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
24315         return ret_conv;
24316 }
24317
24318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24319         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(orig);
24320         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24321         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
24322         return tag_ptr(ret_conv, true);
24323 }
24324
24325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24326         LDKClosingSignedFeeRange o_conv;
24327         o_conv.inner = untag_ptr(o);
24328         o_conv.is_owned = ptr_is_owned(o);
24329         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24330         o_conv = ClosingSignedFeeRange_clone(&o_conv);
24331         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24332         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
24333         return tag_ptr(ret_conv, true);
24334 }
24335
24336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24337         void* e_ptr = untag_ptr(e);
24338         CHECK_ACCESS(e_ptr);
24339         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24340         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24341         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24342         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
24343         return tag_ptr(ret_conv, true);
24344 }
24345
24346 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24347         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(o);
24348         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
24349         return ret_conv;
24350 }
24351
24352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24353         if (!ptr_is_owned(_res)) return;
24354         void* _res_ptr = untag_ptr(_res);
24355         CHECK_ACCESS(_res_ptr);
24356         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
24357         FREE(untag_ptr(_res));
24358         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
24359 }
24360
24361 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
24362         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24363         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
24364         return tag_ptr(ret_conv, true);
24365 }
24366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24367         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(arg);
24368         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
24369         return ret_conv;
24370 }
24371
24372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24373         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(orig);
24374         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24375         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
24376         return tag_ptr(ret_conv, true);
24377 }
24378
24379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24380         LDKCommitmentSigned o_conv;
24381         o_conv.inner = untag_ptr(o);
24382         o_conv.is_owned = ptr_is_owned(o);
24383         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24384         o_conv = CommitmentSigned_clone(&o_conv);
24385         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24386         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
24387         return tag_ptr(ret_conv, true);
24388 }
24389
24390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24391         void* e_ptr = untag_ptr(e);
24392         CHECK_ACCESS(e_ptr);
24393         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24394         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24395         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24396         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
24397         return tag_ptr(ret_conv, true);
24398 }
24399
24400 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24401         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(o);
24402         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
24403         return ret_conv;
24404 }
24405
24406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24407         if (!ptr_is_owned(_res)) return;
24408         void* _res_ptr = untag_ptr(_res);
24409         CHECK_ACCESS(_res_ptr);
24410         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
24411         FREE(untag_ptr(_res));
24412         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
24413 }
24414
24415 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
24416         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24417         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
24418         return tag_ptr(ret_conv, true);
24419 }
24420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24421         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(arg);
24422         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
24423         return ret_conv;
24424 }
24425
24426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24427         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(orig);
24428         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24429         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
24430         return tag_ptr(ret_conv, true);
24431 }
24432
24433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24434         LDKFundingCreated o_conv;
24435         o_conv.inner = untag_ptr(o);
24436         o_conv.is_owned = ptr_is_owned(o);
24437         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24438         o_conv = FundingCreated_clone(&o_conv);
24439         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24440         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
24441         return tag_ptr(ret_conv, true);
24442 }
24443
24444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24445         void* e_ptr = untag_ptr(e);
24446         CHECK_ACCESS(e_ptr);
24447         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24448         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24449         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24450         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
24451         return tag_ptr(ret_conv, true);
24452 }
24453
24454 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24455         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(o);
24456         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
24457         return ret_conv;
24458 }
24459
24460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_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_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
24465         FREE(untag_ptr(_res));
24466         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
24467 }
24468
24469 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
24470         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24471         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
24472         return tag_ptr(ret_conv, true);
24473 }
24474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24475         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(arg);
24476         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
24477         return ret_conv;
24478 }
24479
24480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24481         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(orig);
24482         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24483         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
24484         return tag_ptr(ret_conv, true);
24485 }
24486
24487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24488         LDKFundingSigned o_conv;
24489         o_conv.inner = untag_ptr(o);
24490         o_conv.is_owned = ptr_is_owned(o);
24491         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24492         o_conv = FundingSigned_clone(&o_conv);
24493         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24494         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
24495         return tag_ptr(ret_conv, true);
24496 }
24497
24498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24499         void* e_ptr = untag_ptr(e);
24500         CHECK_ACCESS(e_ptr);
24501         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24502         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24503         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24504         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
24505         return tag_ptr(ret_conv, true);
24506 }
24507
24508 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24509         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(o);
24510         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
24511         return ret_conv;
24512 }
24513
24514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24515         if (!ptr_is_owned(_res)) return;
24516         void* _res_ptr = untag_ptr(_res);
24517         CHECK_ACCESS(_res_ptr);
24518         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
24519         FREE(untag_ptr(_res));
24520         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
24521 }
24522
24523 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
24524         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24525         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
24526         return tag_ptr(ret_conv, true);
24527 }
24528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24529         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(arg);
24530         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
24531         return ret_conv;
24532 }
24533
24534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24535         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(orig);
24536         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24537         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
24538         return tag_ptr(ret_conv, true);
24539 }
24540
24541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24542         LDKChannelReady o_conv;
24543         o_conv.inner = untag_ptr(o);
24544         o_conv.is_owned = ptr_is_owned(o);
24545         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24546         o_conv = ChannelReady_clone(&o_conv);
24547         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24548         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
24549         return tag_ptr(ret_conv, true);
24550 }
24551
24552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24553         void* e_ptr = untag_ptr(e);
24554         CHECK_ACCESS(e_ptr);
24555         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24556         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24557         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24558         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
24559         return tag_ptr(ret_conv, true);
24560 }
24561
24562 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24563         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(o);
24564         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
24565         return ret_conv;
24566 }
24567
24568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24569         if (!ptr_is_owned(_res)) return;
24570         void* _res_ptr = untag_ptr(_res);
24571         CHECK_ACCESS(_res_ptr);
24572         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
24573         FREE(untag_ptr(_res));
24574         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
24575 }
24576
24577 static inline uint64_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
24578         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24579         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
24580         return tag_ptr(ret_conv, true);
24581 }
24582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24583         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(arg);
24584         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
24585         return ret_conv;
24586 }
24587
24588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24589         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(orig);
24590         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24591         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
24592         return tag_ptr(ret_conv, true);
24593 }
24594
24595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24596         LDKInit o_conv;
24597         o_conv.inner = untag_ptr(o);
24598         o_conv.is_owned = ptr_is_owned(o);
24599         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24600         o_conv = Init_clone(&o_conv);
24601         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24602         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
24603         return tag_ptr(ret_conv, true);
24604 }
24605
24606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24607         void* e_ptr = untag_ptr(e);
24608         CHECK_ACCESS(e_ptr);
24609         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24610         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24611         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24612         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
24613         return tag_ptr(ret_conv, true);
24614 }
24615
24616 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24617         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(o);
24618         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
24619         return ret_conv;
24620 }
24621
24622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24623         if (!ptr_is_owned(_res)) return;
24624         void* _res_ptr = untag_ptr(_res);
24625         CHECK_ACCESS(_res_ptr);
24626         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
24627         FREE(untag_ptr(_res));
24628         CResult_InitDecodeErrorZ_free(_res_conv);
24629 }
24630
24631 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
24632         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24633         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
24634         return tag_ptr(ret_conv, true);
24635 }
24636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24637         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(arg);
24638         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
24639         return ret_conv;
24640 }
24641
24642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24643         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(orig);
24644         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24645         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
24646         return tag_ptr(ret_conv, true);
24647 }
24648
24649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24650         LDKOpenChannel o_conv;
24651         o_conv.inner = untag_ptr(o);
24652         o_conv.is_owned = ptr_is_owned(o);
24653         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24654         o_conv = OpenChannel_clone(&o_conv);
24655         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24656         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
24657         return tag_ptr(ret_conv, true);
24658 }
24659
24660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24661         void* e_ptr = untag_ptr(e);
24662         CHECK_ACCESS(e_ptr);
24663         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24664         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24665         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24666         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
24667         return tag_ptr(ret_conv, true);
24668 }
24669
24670 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24671         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(o);
24672         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
24673         return ret_conv;
24674 }
24675
24676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24677         if (!ptr_is_owned(_res)) return;
24678         void* _res_ptr = untag_ptr(_res);
24679         CHECK_ACCESS(_res_ptr);
24680         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
24681         FREE(untag_ptr(_res));
24682         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
24683 }
24684
24685 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
24686         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24687         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
24688         return tag_ptr(ret_conv, true);
24689 }
24690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24691         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(arg);
24692         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
24693         return ret_conv;
24694 }
24695
24696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24697         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(orig);
24698         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24699         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
24700         return tag_ptr(ret_conv, true);
24701 }
24702
24703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24704         LDKRevokeAndACK o_conv;
24705         o_conv.inner = untag_ptr(o);
24706         o_conv.is_owned = ptr_is_owned(o);
24707         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24708         o_conv = RevokeAndACK_clone(&o_conv);
24709         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
24710         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
24711         return tag_ptr(ret_conv, true);
24712 }
24713
24714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24715         void* e_ptr = untag_ptr(e);
24716         CHECK_ACCESS(e_ptr);
24717         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24718         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24719         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
24720         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
24721         return tag_ptr(ret_conv, true);
24722 }
24723
24724 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24725         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(o);
24726         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
24727         return ret_conv;
24728 }
24729
24730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24731         if (!ptr_is_owned(_res)) return;
24732         void* _res_ptr = untag_ptr(_res);
24733         CHECK_ACCESS(_res_ptr);
24734         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
24735         FREE(untag_ptr(_res));
24736         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
24737 }
24738
24739 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
24740         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
24741         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
24742         return tag_ptr(ret_conv, true);
24743 }
24744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24745         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(arg);
24746         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
24747         return ret_conv;
24748 }
24749
24750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24751         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(orig);
24752         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
24753         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
24754         return tag_ptr(ret_conv, true);
24755 }
24756
24757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24758         LDKShutdown o_conv;
24759         o_conv.inner = untag_ptr(o);
24760         o_conv.is_owned = ptr_is_owned(o);
24761         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24762         o_conv = Shutdown_clone(&o_conv);
24763         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
24764         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
24765         return tag_ptr(ret_conv, true);
24766 }
24767
24768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24769         void* e_ptr = untag_ptr(e);
24770         CHECK_ACCESS(e_ptr);
24771         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24772         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24773         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
24774         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
24775         return tag_ptr(ret_conv, true);
24776 }
24777
24778 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24779         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(o);
24780         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
24781         return ret_conv;
24782 }
24783
24784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24785         if (!ptr_is_owned(_res)) return;
24786         void* _res_ptr = untag_ptr(_res);
24787         CHECK_ACCESS(_res_ptr);
24788         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
24789         FREE(untag_ptr(_res));
24790         CResult_ShutdownDecodeErrorZ_free(_res_conv);
24791 }
24792
24793 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
24794         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
24795         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
24796         return tag_ptr(ret_conv, true);
24797 }
24798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24799         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(arg);
24800         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
24801         return ret_conv;
24802 }
24803
24804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24805         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(orig);
24806         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
24807         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
24808         return tag_ptr(ret_conv, true);
24809 }
24810
24811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24812         LDKUpdateFailHTLC o_conv;
24813         o_conv.inner = untag_ptr(o);
24814         o_conv.is_owned = ptr_is_owned(o);
24815         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24816         o_conv = UpdateFailHTLC_clone(&o_conv);
24817         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
24818         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
24819         return tag_ptr(ret_conv, true);
24820 }
24821
24822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24823         void* e_ptr = untag_ptr(e);
24824         CHECK_ACCESS(e_ptr);
24825         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24826         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24827         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
24828         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
24829         return tag_ptr(ret_conv, true);
24830 }
24831
24832 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24833         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(o);
24834         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
24835         return ret_conv;
24836 }
24837
24838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24839         if (!ptr_is_owned(_res)) return;
24840         void* _res_ptr = untag_ptr(_res);
24841         CHECK_ACCESS(_res_ptr);
24842         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
24843         FREE(untag_ptr(_res));
24844         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
24845 }
24846
24847 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
24848         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
24849         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
24850         return tag_ptr(ret_conv, true);
24851 }
24852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24853         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(arg);
24854         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
24855         return ret_conv;
24856 }
24857
24858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24859         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(orig);
24860         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
24861         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
24862         return tag_ptr(ret_conv, true);
24863 }
24864
24865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24866         LDKUpdateFailMalformedHTLC o_conv;
24867         o_conv.inner = untag_ptr(o);
24868         o_conv.is_owned = ptr_is_owned(o);
24869         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24870         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
24871         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
24872         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
24873         return tag_ptr(ret_conv, true);
24874 }
24875
24876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24877         void* e_ptr = untag_ptr(e);
24878         CHECK_ACCESS(e_ptr);
24879         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24880         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24881         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
24882         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
24883         return tag_ptr(ret_conv, true);
24884 }
24885
24886 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24887         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(o);
24888         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
24889         return ret_conv;
24890 }
24891
24892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24893         if (!ptr_is_owned(_res)) return;
24894         void* _res_ptr = untag_ptr(_res);
24895         CHECK_ACCESS(_res_ptr);
24896         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
24897         FREE(untag_ptr(_res));
24898         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
24899 }
24900
24901 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
24902         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
24903         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
24904         return tag_ptr(ret_conv, true);
24905 }
24906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24907         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(arg);
24908         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
24909         return ret_conv;
24910 }
24911
24912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24913         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(orig);
24914         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
24915         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
24916         return tag_ptr(ret_conv, true);
24917 }
24918
24919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24920         LDKUpdateFee o_conv;
24921         o_conv.inner = untag_ptr(o);
24922         o_conv.is_owned = ptr_is_owned(o);
24923         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24924         o_conv = UpdateFee_clone(&o_conv);
24925         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24926         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
24927         return tag_ptr(ret_conv, true);
24928 }
24929
24930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24931         void* e_ptr = untag_ptr(e);
24932         CHECK_ACCESS(e_ptr);
24933         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24934         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24935         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24936         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
24937         return tag_ptr(ret_conv, true);
24938 }
24939
24940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24941         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(o);
24942         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
24943         return ret_conv;
24944 }
24945
24946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24947         if (!ptr_is_owned(_res)) return;
24948         void* _res_ptr = untag_ptr(_res);
24949         CHECK_ACCESS(_res_ptr);
24950         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
24951         FREE(untag_ptr(_res));
24952         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
24953 }
24954
24955 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
24956         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24957         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
24958         return tag_ptr(ret_conv, true);
24959 }
24960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24961         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(arg);
24962         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
24963         return ret_conv;
24964 }
24965
24966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24967         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(orig);
24968         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24969         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
24970         return tag_ptr(ret_conv, true);
24971 }
24972
24973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24974         LDKUpdateFulfillHTLC o_conv;
24975         o_conv.inner = untag_ptr(o);
24976         o_conv.is_owned = ptr_is_owned(o);
24977         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24978         o_conv = UpdateFulfillHTLC_clone(&o_conv);
24979         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24980         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
24981         return tag_ptr(ret_conv, true);
24982 }
24983
24984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24985         void* e_ptr = untag_ptr(e);
24986         CHECK_ACCESS(e_ptr);
24987         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24988         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24989         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24990         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
24991         return tag_ptr(ret_conv, true);
24992 }
24993
24994 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24995         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(o);
24996         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
24997         return ret_conv;
24998 }
24999
25000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25001         if (!ptr_is_owned(_res)) return;
25002         void* _res_ptr = untag_ptr(_res);
25003         CHECK_ACCESS(_res_ptr);
25004         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
25005         FREE(untag_ptr(_res));
25006         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
25007 }
25008
25009 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
25010         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25011         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
25012         return tag_ptr(ret_conv, true);
25013 }
25014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25015         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(arg);
25016         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
25017         return ret_conv;
25018 }
25019
25020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25021         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(orig);
25022         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25023         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
25024         return tag_ptr(ret_conv, true);
25025 }
25026
25027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25028         LDKUpdateAddHTLC o_conv;
25029         o_conv.inner = untag_ptr(o);
25030         o_conv.is_owned = ptr_is_owned(o);
25031         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25032         o_conv = UpdateAddHTLC_clone(&o_conv);
25033         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25034         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
25035         return tag_ptr(ret_conv, true);
25036 }
25037
25038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25039         void* e_ptr = untag_ptr(e);
25040         CHECK_ACCESS(e_ptr);
25041         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25042         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25043         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25044         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
25045         return tag_ptr(ret_conv, true);
25046 }
25047
25048 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25049         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(o);
25050         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
25051         return ret_conv;
25052 }
25053
25054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25055         if (!ptr_is_owned(_res)) return;
25056         void* _res_ptr = untag_ptr(_res);
25057         CHECK_ACCESS(_res_ptr);
25058         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
25059         FREE(untag_ptr(_res));
25060         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
25061 }
25062
25063 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
25064         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25065         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
25066         return tag_ptr(ret_conv, true);
25067 }
25068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25069         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(arg);
25070         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
25071         return ret_conv;
25072 }
25073
25074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25075         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(orig);
25076         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25077         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
25078         return tag_ptr(ret_conv, true);
25079 }
25080
25081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25082         LDKOnionMessage o_conv;
25083         o_conv.inner = untag_ptr(o);
25084         o_conv.is_owned = ptr_is_owned(o);
25085         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25086         o_conv = OnionMessage_clone(&o_conv);
25087         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25088         *ret_conv = CResult_OnionMessageDecodeErrorZ_ok(o_conv);
25089         return tag_ptr(ret_conv, true);
25090 }
25091
25092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25093         void* e_ptr = untag_ptr(e);
25094         CHECK_ACCESS(e_ptr);
25095         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25096         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25097         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25098         *ret_conv = CResult_OnionMessageDecodeErrorZ_err(e_conv);
25099         return tag_ptr(ret_conv, true);
25100 }
25101
25102 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25103         LDKCResult_OnionMessageDecodeErrorZ* o_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(o);
25104         jboolean ret_conv = CResult_OnionMessageDecodeErrorZ_is_ok(o_conv);
25105         return ret_conv;
25106 }
25107
25108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25109         if (!ptr_is_owned(_res)) return;
25110         void* _res_ptr = untag_ptr(_res);
25111         CHECK_ACCESS(_res_ptr);
25112         LDKCResult_OnionMessageDecodeErrorZ _res_conv = *(LDKCResult_OnionMessageDecodeErrorZ*)(_res_ptr);
25113         FREE(untag_ptr(_res));
25114         CResult_OnionMessageDecodeErrorZ_free(_res_conv);
25115 }
25116
25117 static inline uint64_t CResult_OnionMessageDecodeErrorZ_clone_ptr(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR arg) {
25118         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25119         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(arg);
25120         return tag_ptr(ret_conv, true);
25121 }
25122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25123         LDKCResult_OnionMessageDecodeErrorZ* arg_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(arg);
25124         int64_t ret_conv = CResult_OnionMessageDecodeErrorZ_clone_ptr(arg_conv);
25125         return ret_conv;
25126 }
25127
25128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25129         LDKCResult_OnionMessageDecodeErrorZ* orig_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(orig);
25130         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25131         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(orig_conv);
25132         return tag_ptr(ret_conv, true);
25133 }
25134
25135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25136         LDKPing o_conv;
25137         o_conv.inner = untag_ptr(o);
25138         o_conv.is_owned = ptr_is_owned(o);
25139         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25140         o_conv = Ping_clone(&o_conv);
25141         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25142         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
25143         return tag_ptr(ret_conv, true);
25144 }
25145
25146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25147         void* e_ptr = untag_ptr(e);
25148         CHECK_ACCESS(e_ptr);
25149         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25150         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25151         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25152         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
25153         return tag_ptr(ret_conv, true);
25154 }
25155
25156 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25157         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(o);
25158         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
25159         return ret_conv;
25160 }
25161
25162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25163         if (!ptr_is_owned(_res)) return;
25164         void* _res_ptr = untag_ptr(_res);
25165         CHECK_ACCESS(_res_ptr);
25166         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
25167         FREE(untag_ptr(_res));
25168         CResult_PingDecodeErrorZ_free(_res_conv);
25169 }
25170
25171 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
25172         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25173         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
25174         return tag_ptr(ret_conv, true);
25175 }
25176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25177         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(arg);
25178         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
25179         return ret_conv;
25180 }
25181
25182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25183         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(orig);
25184         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25185         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
25186         return tag_ptr(ret_conv, true);
25187 }
25188
25189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25190         LDKPong o_conv;
25191         o_conv.inner = untag_ptr(o);
25192         o_conv.is_owned = ptr_is_owned(o);
25193         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25194         o_conv = Pong_clone(&o_conv);
25195         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
25196         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
25197         return tag_ptr(ret_conv, true);
25198 }
25199
25200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25201         void* e_ptr = untag_ptr(e);
25202         CHECK_ACCESS(e_ptr);
25203         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25204         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25205         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
25206         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
25207         return tag_ptr(ret_conv, true);
25208 }
25209
25210 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25211         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(o);
25212         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
25213         return ret_conv;
25214 }
25215
25216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25217         if (!ptr_is_owned(_res)) return;
25218         void* _res_ptr = untag_ptr(_res);
25219         CHECK_ACCESS(_res_ptr);
25220         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
25221         FREE(untag_ptr(_res));
25222         CResult_PongDecodeErrorZ_free(_res_conv);
25223 }
25224
25225 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
25226         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
25227         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
25228         return tag_ptr(ret_conv, true);
25229 }
25230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25231         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(arg);
25232         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
25233         return ret_conv;
25234 }
25235
25236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25237         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(orig);
25238         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
25239         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
25240         return tag_ptr(ret_conv, true);
25241 }
25242
25243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25244         LDKUnsignedChannelAnnouncement o_conv;
25245         o_conv.inner = untag_ptr(o);
25246         o_conv.is_owned = ptr_is_owned(o);
25247         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25248         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
25249         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25250         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
25251         return tag_ptr(ret_conv, true);
25252 }
25253
25254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25255         void* e_ptr = untag_ptr(e);
25256         CHECK_ACCESS(e_ptr);
25257         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25258         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25259         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25260         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
25261         return tag_ptr(ret_conv, true);
25262 }
25263
25264 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25265         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
25266         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
25267         return ret_conv;
25268 }
25269
25270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25271         if (!ptr_is_owned(_res)) return;
25272         void* _res_ptr = untag_ptr(_res);
25273         CHECK_ACCESS(_res_ptr);
25274         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
25275         FREE(untag_ptr(_res));
25276         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
25277 }
25278
25279 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25280         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25281         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
25282         return tag_ptr(ret_conv, true);
25283 }
25284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25285         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
25286         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25287         return ret_conv;
25288 }
25289
25290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25291         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
25292         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25293         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
25294         return tag_ptr(ret_conv, true);
25295 }
25296
25297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25298         LDKChannelAnnouncement o_conv;
25299         o_conv.inner = untag_ptr(o);
25300         o_conv.is_owned = ptr_is_owned(o);
25301         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25302         o_conv = ChannelAnnouncement_clone(&o_conv);
25303         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25304         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
25305         return tag_ptr(ret_conv, true);
25306 }
25307
25308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25309         void* e_ptr = untag_ptr(e);
25310         CHECK_ACCESS(e_ptr);
25311         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25312         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25313         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25314         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
25315         return tag_ptr(ret_conv, true);
25316 }
25317
25318 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25319         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
25320         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
25321         return ret_conv;
25322 }
25323
25324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25325         if (!ptr_is_owned(_res)) return;
25326         void* _res_ptr = untag_ptr(_res);
25327         CHECK_ACCESS(_res_ptr);
25328         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
25329         FREE(untag_ptr(_res));
25330         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
25331 }
25332
25333 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25334         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25335         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
25336         return tag_ptr(ret_conv, true);
25337 }
25338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25339         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
25340         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25341         return ret_conv;
25342 }
25343
25344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25345         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
25346         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25347         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
25348         return tag_ptr(ret_conv, true);
25349 }
25350
25351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25352         LDKUnsignedChannelUpdate o_conv;
25353         o_conv.inner = untag_ptr(o);
25354         o_conv.is_owned = ptr_is_owned(o);
25355         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25356         o_conv = UnsignedChannelUpdate_clone(&o_conv);
25357         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25358         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
25359         return tag_ptr(ret_conv, true);
25360 }
25361
25362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25363         void* e_ptr = untag_ptr(e);
25364         CHECK_ACCESS(e_ptr);
25365         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25366         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25367         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25368         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
25369         return tag_ptr(ret_conv, true);
25370 }
25371
25372 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25373         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(o);
25374         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
25375         return ret_conv;
25376 }
25377
25378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25379         if (!ptr_is_owned(_res)) return;
25380         void* _res_ptr = untag_ptr(_res);
25381         CHECK_ACCESS(_res_ptr);
25382         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
25383         FREE(untag_ptr(_res));
25384         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
25385 }
25386
25387 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
25388         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25389         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
25390         return tag_ptr(ret_conv, true);
25391 }
25392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25393         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(arg);
25394         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
25395         return ret_conv;
25396 }
25397
25398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25399         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(orig);
25400         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25401         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
25402         return tag_ptr(ret_conv, true);
25403 }
25404
25405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25406         LDKChannelUpdate o_conv;
25407         o_conv.inner = untag_ptr(o);
25408         o_conv.is_owned = ptr_is_owned(o);
25409         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25410         o_conv = ChannelUpdate_clone(&o_conv);
25411         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25412         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
25413         return tag_ptr(ret_conv, true);
25414 }
25415
25416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25417         void* e_ptr = untag_ptr(e);
25418         CHECK_ACCESS(e_ptr);
25419         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25420         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25421         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25422         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
25423         return tag_ptr(ret_conv, true);
25424 }
25425
25426 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25427         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(o);
25428         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
25429         return ret_conv;
25430 }
25431
25432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25433         if (!ptr_is_owned(_res)) return;
25434         void* _res_ptr = untag_ptr(_res);
25435         CHECK_ACCESS(_res_ptr);
25436         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
25437         FREE(untag_ptr(_res));
25438         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
25439 }
25440
25441 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
25442         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25443         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
25444         return tag_ptr(ret_conv, true);
25445 }
25446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25447         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(arg);
25448         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
25449         return ret_conv;
25450 }
25451
25452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25453         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(orig);
25454         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25455         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
25456         return tag_ptr(ret_conv, true);
25457 }
25458
25459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25460         LDKErrorMessage o_conv;
25461         o_conv.inner = untag_ptr(o);
25462         o_conv.is_owned = ptr_is_owned(o);
25463         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25464         o_conv = ErrorMessage_clone(&o_conv);
25465         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25466         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
25467         return tag_ptr(ret_conv, true);
25468 }
25469
25470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25471         void* e_ptr = untag_ptr(e);
25472         CHECK_ACCESS(e_ptr);
25473         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25474         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25475         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25476         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
25477         return tag_ptr(ret_conv, true);
25478 }
25479
25480 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25481         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(o);
25482         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
25483         return ret_conv;
25484 }
25485
25486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25487         if (!ptr_is_owned(_res)) return;
25488         void* _res_ptr = untag_ptr(_res);
25489         CHECK_ACCESS(_res_ptr);
25490         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
25491         FREE(untag_ptr(_res));
25492         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
25493 }
25494
25495 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
25496         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25497         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
25498         return tag_ptr(ret_conv, true);
25499 }
25500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25501         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(arg);
25502         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
25503         return ret_conv;
25504 }
25505
25506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25507         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(orig);
25508         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25509         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
25510         return tag_ptr(ret_conv, true);
25511 }
25512
25513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25514         LDKWarningMessage o_conv;
25515         o_conv.inner = untag_ptr(o);
25516         o_conv.is_owned = ptr_is_owned(o);
25517         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25518         o_conv = WarningMessage_clone(&o_conv);
25519         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25520         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
25521         return tag_ptr(ret_conv, true);
25522 }
25523
25524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25525         void* e_ptr = untag_ptr(e);
25526         CHECK_ACCESS(e_ptr);
25527         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25528         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25529         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25530         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
25531         return tag_ptr(ret_conv, true);
25532 }
25533
25534 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25535         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(o);
25536         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
25537         return ret_conv;
25538 }
25539
25540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25541         if (!ptr_is_owned(_res)) return;
25542         void* _res_ptr = untag_ptr(_res);
25543         CHECK_ACCESS(_res_ptr);
25544         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
25545         FREE(untag_ptr(_res));
25546         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
25547 }
25548
25549 static inline uint64_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
25550         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25551         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
25552         return tag_ptr(ret_conv, true);
25553 }
25554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25555         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(arg);
25556         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
25557         return ret_conv;
25558 }
25559
25560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25561         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(orig);
25562         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25563         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
25564         return tag_ptr(ret_conv, true);
25565 }
25566
25567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25568         LDKUnsignedNodeAnnouncement o_conv;
25569         o_conv.inner = untag_ptr(o);
25570         o_conv.is_owned = ptr_is_owned(o);
25571         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25572         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
25573         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25574         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
25575         return tag_ptr(ret_conv, true);
25576 }
25577
25578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25579         void* e_ptr = untag_ptr(e);
25580         CHECK_ACCESS(e_ptr);
25581         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25582         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25583         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25584         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
25585         return tag_ptr(ret_conv, true);
25586 }
25587
25588 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25589         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(o);
25590         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
25591         return ret_conv;
25592 }
25593
25594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25595         if (!ptr_is_owned(_res)) return;
25596         void* _res_ptr = untag_ptr(_res);
25597         CHECK_ACCESS(_res_ptr);
25598         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
25599         FREE(untag_ptr(_res));
25600         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
25601 }
25602
25603 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25604         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25605         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
25606         return tag_ptr(ret_conv, true);
25607 }
25608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25609         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
25610         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25611         return ret_conv;
25612 }
25613
25614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25615         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
25616         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25617         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
25618         return tag_ptr(ret_conv, true);
25619 }
25620
25621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25622         LDKNodeAnnouncement o_conv;
25623         o_conv.inner = untag_ptr(o);
25624         o_conv.is_owned = ptr_is_owned(o);
25625         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25626         o_conv = NodeAnnouncement_clone(&o_conv);
25627         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
25628         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
25629         return tag_ptr(ret_conv, true);
25630 }
25631
25632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25633         void* e_ptr = untag_ptr(e);
25634         CHECK_ACCESS(e_ptr);
25635         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25636         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25637         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
25638         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
25639         return tag_ptr(ret_conv, true);
25640 }
25641
25642 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25643         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(o);
25644         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
25645         return ret_conv;
25646 }
25647
25648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25649         if (!ptr_is_owned(_res)) return;
25650         void* _res_ptr = untag_ptr(_res);
25651         CHECK_ACCESS(_res_ptr);
25652         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
25653         FREE(untag_ptr(_res));
25654         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
25655 }
25656
25657 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25658         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
25659         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
25660         return tag_ptr(ret_conv, true);
25661 }
25662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25663         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
25664         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25665         return ret_conv;
25666 }
25667
25668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25669         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
25670         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
25671         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
25672         return tag_ptr(ret_conv, true);
25673 }
25674
25675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25676         LDKQueryShortChannelIds o_conv;
25677         o_conv.inner = untag_ptr(o);
25678         o_conv.is_owned = ptr_is_owned(o);
25679         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25680         o_conv = QueryShortChannelIds_clone(&o_conv);
25681         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
25682         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
25683         return tag_ptr(ret_conv, true);
25684 }
25685
25686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25687         void* e_ptr = untag_ptr(e);
25688         CHECK_ACCESS(e_ptr);
25689         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25690         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25691         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
25692         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
25693         return tag_ptr(ret_conv, true);
25694 }
25695
25696 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25697         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(o);
25698         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
25699         return ret_conv;
25700 }
25701
25702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25703         if (!ptr_is_owned(_res)) return;
25704         void* _res_ptr = untag_ptr(_res);
25705         CHECK_ACCESS(_res_ptr);
25706         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
25707         FREE(untag_ptr(_res));
25708         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
25709 }
25710
25711 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
25712         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
25713         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
25714         return tag_ptr(ret_conv, true);
25715 }
25716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25717         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(arg);
25718         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
25719         return ret_conv;
25720 }
25721
25722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25723         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(orig);
25724         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
25725         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
25726         return tag_ptr(ret_conv, true);
25727 }
25728
25729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25730         LDKReplyShortChannelIdsEnd o_conv;
25731         o_conv.inner = untag_ptr(o);
25732         o_conv.is_owned = ptr_is_owned(o);
25733         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25734         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
25735         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
25736         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
25737         return tag_ptr(ret_conv, true);
25738 }
25739
25740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25741         void* e_ptr = untag_ptr(e);
25742         CHECK_ACCESS(e_ptr);
25743         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25744         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25745         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
25746         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
25747         return tag_ptr(ret_conv, true);
25748 }
25749
25750 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25751         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(o);
25752         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
25753         return ret_conv;
25754 }
25755
25756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25757         if (!ptr_is_owned(_res)) return;
25758         void* _res_ptr = untag_ptr(_res);
25759         CHECK_ACCESS(_res_ptr);
25760         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
25761         FREE(untag_ptr(_res));
25762         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
25763 }
25764
25765 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
25766         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
25767         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
25768         return tag_ptr(ret_conv, true);
25769 }
25770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25771         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(arg);
25772         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
25773         return ret_conv;
25774 }
25775
25776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25777         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(orig);
25778         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
25779         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
25780         return tag_ptr(ret_conv, true);
25781 }
25782
25783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25784         LDKQueryChannelRange o_conv;
25785         o_conv.inner = untag_ptr(o);
25786         o_conv.is_owned = ptr_is_owned(o);
25787         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25788         o_conv = QueryChannelRange_clone(&o_conv);
25789         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
25790         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
25791         return tag_ptr(ret_conv, true);
25792 }
25793
25794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25795         void* e_ptr = untag_ptr(e);
25796         CHECK_ACCESS(e_ptr);
25797         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25798         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25799         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
25800         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
25801         return tag_ptr(ret_conv, true);
25802 }
25803
25804 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25805         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(o);
25806         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
25807         return ret_conv;
25808 }
25809
25810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25811         if (!ptr_is_owned(_res)) return;
25812         void* _res_ptr = untag_ptr(_res);
25813         CHECK_ACCESS(_res_ptr);
25814         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
25815         FREE(untag_ptr(_res));
25816         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
25817 }
25818
25819 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
25820         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
25821         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
25822         return tag_ptr(ret_conv, true);
25823 }
25824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25825         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(arg);
25826         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
25827         return ret_conv;
25828 }
25829
25830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25831         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(orig);
25832         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
25833         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
25834         return tag_ptr(ret_conv, true);
25835 }
25836
25837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25838         LDKReplyChannelRange o_conv;
25839         o_conv.inner = untag_ptr(o);
25840         o_conv.is_owned = ptr_is_owned(o);
25841         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25842         o_conv = ReplyChannelRange_clone(&o_conv);
25843         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
25844         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
25845         return tag_ptr(ret_conv, true);
25846 }
25847
25848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25849         void* e_ptr = untag_ptr(e);
25850         CHECK_ACCESS(e_ptr);
25851         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25852         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25853         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
25854         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
25855         return tag_ptr(ret_conv, true);
25856 }
25857
25858 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25859         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(o);
25860         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
25861         return ret_conv;
25862 }
25863
25864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25865         if (!ptr_is_owned(_res)) return;
25866         void* _res_ptr = untag_ptr(_res);
25867         CHECK_ACCESS(_res_ptr);
25868         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
25869         FREE(untag_ptr(_res));
25870         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
25871 }
25872
25873 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
25874         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
25875         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
25876         return tag_ptr(ret_conv, true);
25877 }
25878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25879         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(arg);
25880         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
25881         return ret_conv;
25882 }
25883
25884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25885         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(orig);
25886         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
25887         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
25888         return tag_ptr(ret_conv, true);
25889 }
25890
25891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25892         LDKGossipTimestampFilter o_conv;
25893         o_conv.inner = untag_ptr(o);
25894         o_conv.is_owned = ptr_is_owned(o);
25895         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25896         o_conv = GossipTimestampFilter_clone(&o_conv);
25897         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
25898         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
25899         return tag_ptr(ret_conv, true);
25900 }
25901
25902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25903         void* e_ptr = untag_ptr(e);
25904         CHECK_ACCESS(e_ptr);
25905         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25906         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25907         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
25908         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
25909         return tag_ptr(ret_conv, true);
25910 }
25911
25912 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25913         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(o);
25914         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
25915         return ret_conv;
25916 }
25917
25918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25919         if (!ptr_is_owned(_res)) return;
25920         void* _res_ptr = untag_ptr(_res);
25921         CHECK_ACCESS(_res_ptr);
25922         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
25923         FREE(untag_ptr(_res));
25924         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
25925 }
25926
25927 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
25928         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
25929         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
25930         return tag_ptr(ret_conv, true);
25931 }
25932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25933         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(arg);
25934         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
25935         return ret_conv;
25936 }
25937
25938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25939         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(orig);
25940         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
25941         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
25942         return tag_ptr(ret_conv, true);
25943 }
25944
25945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
25946         LDKCVec_PhantomRouteHintsZ _res_constr;
25947         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
25948         if (_res_constr.datalen > 0)
25949                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
25950         else
25951                 _res_constr.data = NULL;
25952         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
25953         for (size_t t = 0; t < _res_constr.datalen; t++) {
25954                 int64_t _res_conv_19 = _res_vals[t];
25955                 LDKPhantomRouteHints _res_conv_19_conv;
25956                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
25957                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
25958                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
25959                 _res_constr.data[t] = _res_conv_19_conv;
25960         }
25961         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
25962         CVec_PhantomRouteHintsZ_free(_res_constr);
25963 }
25964
25965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25966         LDKInvoice o_conv;
25967         o_conv.inner = untag_ptr(o);
25968         o_conv.is_owned = ptr_is_owned(o);
25969         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25970         o_conv = Invoice_clone(&o_conv);
25971         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25972         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
25973         return tag_ptr(ret_conv, true);
25974 }
25975
25976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25977         void* e_ptr = untag_ptr(e);
25978         CHECK_ACCESS(e_ptr);
25979         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
25980         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)untag_ptr(e));
25981         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25982         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
25983         return tag_ptr(ret_conv, true);
25984 }
25985
25986 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25987         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(o);
25988         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
25989         return ret_conv;
25990 }
25991
25992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25993         if (!ptr_is_owned(_res)) return;
25994         void* _res_ptr = untag_ptr(_res);
25995         CHECK_ACCESS(_res_ptr);
25996         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
25997         FREE(untag_ptr(_res));
25998         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
25999 }
26000
26001 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
26002         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26003         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
26004         return tag_ptr(ret_conv, true);
26005 }
26006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26007         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(arg);
26008         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
26009         return ret_conv;
26010 }
26011
26012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26013         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(orig);
26014         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26015         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
26016         return tag_ptr(ret_conv, true);
26017 }
26018
26019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
26020         void* o_ptr = untag_ptr(o);
26021         CHECK_ACCESS(o_ptr);
26022         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
26023         if (o_conv.free == LDKFilter_JCalls_free) {
26024                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26025                 LDKFilter_JCalls_cloned(&o_conv);
26026         }
26027         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
26028         *ret_copy = COption_FilterZ_some(o_conv);
26029         int64_t ret_ref = tag_ptr(ret_copy, true);
26030         return ret_ref;
26031 }
26032
26033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
26034         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
26035         *ret_copy = COption_FilterZ_none();
26036         int64_t ret_ref = tag_ptr(ret_copy, true);
26037         return ret_ref;
26038 }
26039
26040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26041         if (!ptr_is_owned(_res)) return;
26042         void* _res_ptr = untag_ptr(_res);
26043         CHECK_ACCESS(_res_ptr);
26044         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
26045         FREE(untag_ptr(_res));
26046         COption_FilterZ_free(_res_conv);
26047 }
26048
26049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26050         LDKLockedChannelMonitor o_conv;
26051         o_conv.inner = untag_ptr(o);
26052         o_conv.is_owned = ptr_is_owned(o);
26053         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26054         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
26055         
26056         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
26057         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
26058         return tag_ptr(ret_conv, true);
26059 }
26060
26061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
26062         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
26063         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
26064         return tag_ptr(ret_conv, true);
26065 }
26066
26067 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26068         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(o);
26069         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
26070         return ret_conv;
26071 }
26072
26073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26074         if (!ptr_is_owned(_res)) return;
26075         void* _res_ptr = untag_ptr(_res);
26076         CHECK_ACCESS(_res_ptr);
26077         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
26078         FREE(untag_ptr(_res));
26079         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
26080 }
26081
26082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26083         LDKCVec_OutPointZ _res_constr;
26084         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26085         if (_res_constr.datalen > 0)
26086                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
26087         else
26088                 _res_constr.data = NULL;
26089         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26090         for (size_t k = 0; k < _res_constr.datalen; k++) {
26091                 int64_t _res_conv_10 = _res_vals[k];
26092                 LDKOutPoint _res_conv_10_conv;
26093                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
26094                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
26095                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
26096                 _res_constr.data[k] = _res_conv_10_conv;
26097         }
26098         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26099         CVec_OutPointZ_free(_res_constr);
26100 }
26101
26102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorUpdateIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26103         LDKCVec_MonitorUpdateIdZ _res_constr;
26104         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26105         if (_res_constr.datalen > 0)
26106                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
26107         else
26108                 _res_constr.data = NULL;
26109         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26110         for (size_t r = 0; r < _res_constr.datalen; r++) {
26111                 int64_t _res_conv_17 = _res_vals[r];
26112                 LDKMonitorUpdateId _res_conv_17_conv;
26113                 _res_conv_17_conv.inner = untag_ptr(_res_conv_17);
26114                 _res_conv_17_conv.is_owned = ptr_is_owned(_res_conv_17);
26115                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_17_conv);
26116                 _res_constr.data[r] = _res_conv_17_conv;
26117         }
26118         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26119         CVec_MonitorUpdateIdZ_free(_res_constr);
26120 }
26121
26122 static inline uint64_t C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR arg) {
26123         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
26124         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(arg);
26125         return tag_ptr(ret_conv, true);
26126 }
26127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26128         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* arg_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(arg);
26129         int64_t ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(arg_conv);
26130         return ret_conv;
26131 }
26132
26133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26134         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* orig_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(orig);
26135         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
26136         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(orig_conv);
26137         return tag_ptr(ret_conv, true);
26138 }
26139
26140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_tArray b) {
26141         LDKOutPoint a_conv;
26142         a_conv.inner = untag_ptr(a);
26143         a_conv.is_owned = ptr_is_owned(a);
26144         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26145         a_conv = OutPoint_clone(&a_conv);
26146         LDKCVec_MonitorUpdateIdZ b_constr;
26147         b_constr.datalen = (*env)->GetArrayLength(env, b);
26148         if (b_constr.datalen > 0)
26149                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
26150         else
26151                 b_constr.data = NULL;
26152         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
26153         for (size_t r = 0; r < b_constr.datalen; r++) {
26154                 int64_t b_conv_17 = b_vals[r];
26155                 LDKMonitorUpdateId b_conv_17_conv;
26156                 b_conv_17_conv.inner = untag_ptr(b_conv_17);
26157                 b_conv_17_conv.is_owned = ptr_is_owned(b_conv_17);
26158                 CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv_17_conv);
26159                 b_conv_17_conv = MonitorUpdateId_clone(&b_conv_17_conv);
26160                 b_constr.data[r] = b_conv_17_conv;
26161         }
26162         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
26163         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
26164         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(a_conv, b_constr);
26165         return tag_ptr(ret_conv, true);
26166 }
26167
26168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26169         if (!ptr_is_owned(_res)) return;
26170         void* _res_ptr = untag_ptr(_res);
26171         CHECK_ACCESS(_res_ptr);
26172         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_ptr);
26173         FREE(untag_ptr(_res));
26174         C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(_res_conv);
26175 }
26176
26177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1OutPointCVec_1MonitorUpdateIdZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26178         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res_constr;
26179         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26180         if (_res_constr.datalen > 0)
26181                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ Elements");
26182         else
26183                 _res_constr.data = NULL;
26184         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26185         for (size_t p = 0; p < _res_constr.datalen; p++) {
26186                 int64_t _res_conv_41 = _res_vals[p];
26187                 void* _res_conv_41_ptr = untag_ptr(_res_conv_41);
26188                 CHECK_ACCESS(_res_conv_41_ptr);
26189                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv_41_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_conv_41_ptr);
26190                 FREE(untag_ptr(_res_conv_41));
26191                 _res_constr.data[p] = _res_conv_41_conv;
26192         }
26193         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26194         CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(_res_constr);
26195 }
26196
26197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26198         if (!ptr_is_owned(this_ptr)) return;
26199         void* this_ptr_ptr = untag_ptr(this_ptr);
26200         CHECK_ACCESS(this_ptr_ptr);
26201         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
26202         FREE(untag_ptr(this_ptr));
26203         PaymentPurpose_free(this_ptr_conv);
26204 }
26205
26206 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
26207         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
26208         *ret_copy = PaymentPurpose_clone(arg);
26209         int64_t ret_ref = tag_ptr(ret_copy, true);
26210         return ret_ref;
26211 }
26212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26213         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)untag_ptr(arg);
26214         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
26215         return ret_conv;
26216 }
26217
26218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26219         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)untag_ptr(orig);
26220         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
26221         *ret_copy = PaymentPurpose_clone(orig_conv);
26222         int64_t ret_ref = tag_ptr(ret_copy, true);
26223         return ret_ref;
26224 }
26225
26226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
26227         LDKThirtyTwoBytes payment_preimage_ref;
26228         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
26229         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
26230         LDKThirtyTwoBytes payment_secret_ref;
26231         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
26232         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
26233         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
26234         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
26235         int64_t ret_ref = tag_ptr(ret_copy, true);
26236         return ret_ref;
26237 }
26238
26239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
26240         LDKThirtyTwoBytes a_ref;
26241         CHECK((*env)->GetArrayLength(env, a) == 32);
26242         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
26243         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
26244         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
26245         int64_t ret_ref = tag_ptr(ret_copy, true);
26246         return ret_ref;
26247 }
26248
26249 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26250         LDKPaymentPurpose* a_conv = (LDKPaymentPurpose*)untag_ptr(a);
26251         LDKPaymentPurpose* b_conv = (LDKPaymentPurpose*)untag_ptr(b);
26252         jboolean ret_conv = PaymentPurpose_eq(a_conv, b_conv);
26253         return ret_conv;
26254 }
26255
26256 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
26257         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)untag_ptr(obj);
26258         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
26259         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26260         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26261         CVec_u8Z_free(ret_var);
26262         return ret_arr;
26263 }
26264
26265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26266         LDKu8slice ser_ref;
26267         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26268         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26269         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
26270         *ret_conv = PaymentPurpose_read(ser_ref);
26271         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26272         return tag_ptr(ret_conv, true);
26273 }
26274
26275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PathFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26276         if (!ptr_is_owned(this_ptr)) return;
26277         void* this_ptr_ptr = untag_ptr(this_ptr);
26278         CHECK_ACCESS(this_ptr_ptr);
26279         LDKPathFailure this_ptr_conv = *(LDKPathFailure*)(this_ptr_ptr);
26280         FREE(untag_ptr(this_ptr));
26281         PathFailure_free(this_ptr_conv);
26282 }
26283
26284 static inline uint64_t PathFailure_clone_ptr(LDKPathFailure *NONNULL_PTR arg) {
26285         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
26286         *ret_copy = PathFailure_clone(arg);
26287         int64_t ret_ref = tag_ptr(ret_copy, true);
26288         return ret_ref;
26289 }
26290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26291         LDKPathFailure* arg_conv = (LDKPathFailure*)untag_ptr(arg);
26292         int64_t ret_conv = PathFailure_clone_ptr(arg_conv);
26293         return ret_conv;
26294 }
26295
26296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26297         LDKPathFailure* orig_conv = (LDKPathFailure*)untag_ptr(orig);
26298         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
26299         *ret_copy = PathFailure_clone(orig_conv);
26300         int64_t ret_ref = tag_ptr(ret_copy, true);
26301         return ret_ref;
26302 }
26303
26304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1initial_1send(JNIEnv *env, jclass clz, int64_t err) {
26305         void* err_ptr = untag_ptr(err);
26306         CHECK_ACCESS(err_ptr);
26307         LDKAPIError err_conv = *(LDKAPIError*)(err_ptr);
26308         err_conv = APIError_clone((LDKAPIError*)untag_ptr(err));
26309         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
26310         *ret_copy = PathFailure_initial_send(err_conv);
26311         int64_t ret_ref = tag_ptr(ret_copy, true);
26312         return ret_ref;
26313 }
26314
26315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1on_1path(JNIEnv *env, jclass clz, int64_t network_update) {
26316         void* network_update_ptr = untag_ptr(network_update);
26317         CHECK_ACCESS(network_update_ptr);
26318         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
26319         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(network_update));
26320         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
26321         *ret_copy = PathFailure_on_path(network_update_conv);
26322         int64_t ret_ref = tag_ptr(ret_copy, true);
26323         return ret_ref;
26324 }
26325
26326 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PathFailure_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26327         LDKPathFailure* a_conv = (LDKPathFailure*)untag_ptr(a);
26328         LDKPathFailure* b_conv = (LDKPathFailure*)untag_ptr(b);
26329         jboolean ret_conv = PathFailure_eq(a_conv, b_conv);
26330         return ret_conv;
26331 }
26332
26333 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PathFailure_1write(JNIEnv *env, jclass clz, int64_t obj) {
26334         LDKPathFailure* obj_conv = (LDKPathFailure*)untag_ptr(obj);
26335         LDKCVec_u8Z ret_var = PathFailure_write(obj_conv);
26336         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26337         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26338         CVec_u8Z_free(ret_var);
26339         return ret_arr;
26340 }
26341
26342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26343         LDKu8slice ser_ref;
26344         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26345         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26346         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
26347         *ret_conv = PathFailure_read(ser_ref);
26348         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26349         return tag_ptr(ret_conv, true);
26350 }
26351
26352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26353         if (!ptr_is_owned(this_ptr)) return;
26354         void* this_ptr_ptr = untag_ptr(this_ptr);
26355         CHECK_ACCESS(this_ptr_ptr);
26356         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
26357         FREE(untag_ptr(this_ptr));
26358         ClosureReason_free(this_ptr_conv);
26359 }
26360
26361 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
26362         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26363         *ret_copy = ClosureReason_clone(arg);
26364         int64_t ret_ref = tag_ptr(ret_copy, true);
26365         return ret_ref;
26366 }
26367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26368         LDKClosureReason* arg_conv = (LDKClosureReason*)untag_ptr(arg);
26369         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
26370         return ret_conv;
26371 }
26372
26373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26374         LDKClosureReason* orig_conv = (LDKClosureReason*)untag_ptr(orig);
26375         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26376         *ret_copy = ClosureReason_clone(orig_conv);
26377         int64_t ret_ref = tag_ptr(ret_copy, true);
26378         return ret_ref;
26379 }
26380
26381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
26382         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
26383         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26384         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
26385         int64_t ret_ref = tag_ptr(ret_copy, true);
26386         return ret_ref;
26387 }
26388
26389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
26390         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26391         *ret_copy = ClosureReason_holder_force_closed();
26392         int64_t ret_ref = tag_ptr(ret_copy, true);
26393         return ret_ref;
26394 }
26395
26396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
26397         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26398         *ret_copy = ClosureReason_cooperative_closure();
26399         int64_t ret_ref = tag_ptr(ret_copy, true);
26400         return ret_ref;
26401 }
26402
26403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
26404         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26405         *ret_copy = ClosureReason_commitment_tx_confirmed();
26406         int64_t ret_ref = tag_ptr(ret_copy, true);
26407         return ret_ref;
26408 }
26409
26410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
26411         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26412         *ret_copy = ClosureReason_funding_timed_out();
26413         int64_t ret_ref = tag_ptr(ret_copy, true);
26414         return ret_ref;
26415 }
26416
26417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
26418         LDKStr err_conv = java_to_owned_str(env, err);
26419         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26420         *ret_copy = ClosureReason_processing_error(err_conv);
26421         int64_t ret_ref = tag_ptr(ret_copy, true);
26422         return ret_ref;
26423 }
26424
26425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
26426         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26427         *ret_copy = ClosureReason_disconnected_peer();
26428         int64_t ret_ref = tag_ptr(ret_copy, true);
26429         return ret_ref;
26430 }
26431
26432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
26433         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26434         *ret_copy = ClosureReason_outdated_channel_manager();
26435         int64_t ret_ref = tag_ptr(ret_copy, true);
26436         return ret_ref;
26437 }
26438
26439 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosureReason_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26440         LDKClosureReason* a_conv = (LDKClosureReason*)untag_ptr(a);
26441         LDKClosureReason* b_conv = (LDKClosureReason*)untag_ptr(b);
26442         jboolean ret_conv = ClosureReason_eq(a_conv, b_conv);
26443         return ret_conv;
26444 }
26445
26446 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
26447         LDKClosureReason* obj_conv = (LDKClosureReason*)untag_ptr(obj);
26448         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
26449         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26450         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26451         CVec_u8Z_free(ret_var);
26452         return ret_arr;
26453 }
26454
26455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26456         LDKu8slice ser_ref;
26457         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26458         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26459         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
26460         *ret_conv = ClosureReason_read(ser_ref);
26461         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26462         return tag_ptr(ret_conv, true);
26463 }
26464
26465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26466         if (!ptr_is_owned(this_ptr)) return;
26467         void* this_ptr_ptr = untag_ptr(this_ptr);
26468         CHECK_ACCESS(this_ptr_ptr);
26469         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
26470         FREE(untag_ptr(this_ptr));
26471         HTLCDestination_free(this_ptr_conv);
26472 }
26473
26474 static inline uint64_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
26475         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26476         *ret_copy = HTLCDestination_clone(arg);
26477         int64_t ret_ref = tag_ptr(ret_copy, true);
26478         return ret_ref;
26479 }
26480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26481         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)untag_ptr(arg);
26482         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
26483         return ret_conv;
26484 }
26485
26486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26487         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)untag_ptr(orig);
26488         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26489         *ret_copy = HTLCDestination_clone(orig_conv);
26490         int64_t ret_ref = tag_ptr(ret_copy, true);
26491         return ret_ref;
26492 }
26493
26494 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) {
26495         LDKPublicKey node_id_ref;
26496         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26497         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26498         LDKThirtyTwoBytes channel_id_ref;
26499         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
26500         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
26501         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26502         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
26503         int64_t ret_ref = tag_ptr(ret_copy, true);
26504         return ret_ref;
26505 }
26506
26507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1unknown_1next_1hop(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
26508         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26509         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
26510         int64_t ret_ref = tag_ptr(ret_copy, true);
26511         return ret_ref;
26512 }
26513
26514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1invalid_1forward(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
26515         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26516         *ret_copy = HTLCDestination_invalid_forward(requested_forward_scid);
26517         int64_t ret_ref = tag_ptr(ret_copy, true);
26518         return ret_ref;
26519 }
26520
26521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1failed_1payment(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
26522         LDKThirtyTwoBytes payment_hash_ref;
26523         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26524         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26525         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26526         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
26527         int64_t ret_ref = tag_ptr(ret_copy, true);
26528         return ret_ref;
26529 }
26530
26531 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26532         LDKHTLCDestination* a_conv = (LDKHTLCDestination*)untag_ptr(a);
26533         LDKHTLCDestination* b_conv = (LDKHTLCDestination*)untag_ptr(b);
26534         jboolean ret_conv = HTLCDestination_eq(a_conv, b_conv);
26535         return ret_conv;
26536 }
26537
26538 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1write(JNIEnv *env, jclass clz, int64_t obj) {
26539         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)untag_ptr(obj);
26540         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
26541         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26542         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26543         CVec_u8Z_free(ret_var);
26544         return ret_arr;
26545 }
26546
26547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26548         LDKu8slice ser_ref;
26549         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26550         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26551         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
26552         *ret_conv = HTLCDestination_read(ser_ref);
26553         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26554         return tag_ptr(ret_conv, true);
26555 }
26556
26557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26558         if (!ptr_is_owned(this_ptr)) return;
26559         void* this_ptr_ptr = untag_ptr(this_ptr);
26560         CHECK_ACCESS(this_ptr_ptr);
26561         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
26562         FREE(untag_ptr(this_ptr));
26563         Event_free(this_ptr_conv);
26564 }
26565
26566 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
26567         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26568         *ret_copy = Event_clone(arg);
26569         int64_t ret_ref = tag_ptr(ret_copy, true);
26570         return ret_ref;
26571 }
26572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26573         LDKEvent* arg_conv = (LDKEvent*)untag_ptr(arg);
26574         int64_t ret_conv = Event_clone_ptr(arg_conv);
26575         return ret_conv;
26576 }
26577
26578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26579         LDKEvent* orig_conv = (LDKEvent*)untag_ptr(orig);
26580         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26581         *ret_copy = Event_clone(orig_conv);
26582         int64_t ret_ref = tag_ptr(ret_copy, true);
26583         return ret_ref;
26584 }
26585
26586 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) {
26587         LDKThirtyTwoBytes temporary_channel_id_ref;
26588         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
26589         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
26590         LDKPublicKey counterparty_node_id_ref;
26591         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
26592         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
26593         LDKCVec_u8Z output_script_ref;
26594         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
26595         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
26596         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
26597         LDKU128 user_channel_id_ref;
26598         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
26599         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
26600         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26601         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id_ref);
26602         int64_t ret_ref = tag_ptr(ret_copy, true);
26603         return ret_ref;
26604 }
26605
26606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1claimable(JNIEnv *env, jclass clz, int8_tArray receiver_node_id, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose, int8_tArray via_channel_id, int64_t via_user_channel_id) {
26607         LDKPublicKey receiver_node_id_ref;
26608         CHECK((*env)->GetArrayLength(env, receiver_node_id) == 33);
26609         (*env)->GetByteArrayRegion(env, receiver_node_id, 0, 33, receiver_node_id_ref.compressed_form);
26610         LDKThirtyTwoBytes payment_hash_ref;
26611         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26612         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26613         void* purpose_ptr = untag_ptr(purpose);
26614         CHECK_ACCESS(purpose_ptr);
26615         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
26616         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
26617         LDKThirtyTwoBytes via_channel_id_ref;
26618         CHECK((*env)->GetArrayLength(env, via_channel_id) == 32);
26619         (*env)->GetByteArrayRegion(env, via_channel_id, 0, 32, via_channel_id_ref.data);
26620         void* via_user_channel_id_ptr = untag_ptr(via_user_channel_id);
26621         CHECK_ACCESS(via_user_channel_id_ptr);
26622         LDKCOption_u128Z via_user_channel_id_conv = *(LDKCOption_u128Z*)(via_user_channel_id_ptr);
26623         via_user_channel_id_conv = COption_u128Z_clone((LDKCOption_u128Z*)untag_ptr(via_user_channel_id));
26624         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26625         *ret_copy = Event_payment_claimable(receiver_node_id_ref, payment_hash_ref, amount_msat, purpose_conv, via_channel_id_ref, via_user_channel_id_conv);
26626         int64_t ret_ref = tag_ptr(ret_copy, true);
26627         return ret_ref;
26628 }
26629
26630 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) {
26631         LDKPublicKey receiver_node_id_ref;
26632         CHECK((*env)->GetArrayLength(env, receiver_node_id) == 33);
26633         (*env)->GetByteArrayRegion(env, receiver_node_id, 0, 33, receiver_node_id_ref.compressed_form);
26634         LDKThirtyTwoBytes payment_hash_ref;
26635         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26636         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26637         void* purpose_ptr = untag_ptr(purpose);
26638         CHECK_ACCESS(purpose_ptr);
26639         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
26640         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
26641         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26642         *ret_copy = Event_payment_claimed(receiver_node_id_ref, payment_hash_ref, amount_msat, purpose_conv);
26643         int64_t ret_ref = tag_ptr(ret_copy, true);
26644         return ret_ref;
26645 }
26646
26647 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) {
26648         LDKThirtyTwoBytes payment_id_ref;
26649         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26650         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26651         LDKThirtyTwoBytes payment_preimage_ref;
26652         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
26653         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
26654         LDKThirtyTwoBytes payment_hash_ref;
26655         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26656         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26657         void* fee_paid_msat_ptr = untag_ptr(fee_paid_msat);
26658         CHECK_ACCESS(fee_paid_msat_ptr);
26659         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
26660         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_paid_msat));
26661         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26662         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
26663         int64_t ret_ref = tag_ptr(ret_copy, true);
26664         return ret_ref;
26665 }
26666
26667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
26668         LDKThirtyTwoBytes payment_id_ref;
26669         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26670         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26671         LDKThirtyTwoBytes payment_hash_ref;
26672         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26673         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26674         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26675         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
26676         int64_t ret_ref = tag_ptr(ret_copy, true);
26677         return ret_ref;
26678 }
26679
26680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1successful(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_tArray path) {
26681         LDKThirtyTwoBytes payment_id_ref;
26682         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26683         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26684         LDKThirtyTwoBytes payment_hash_ref;
26685         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26686         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26687         LDKCVec_RouteHopZ path_constr;
26688         path_constr.datalen = (*env)->GetArrayLength(env, path);
26689         if (path_constr.datalen > 0)
26690                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
26691         else
26692                 path_constr.data = NULL;
26693         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
26694         for (size_t k = 0; k < path_constr.datalen; k++) {
26695                 int64_t path_conv_10 = path_vals[k];
26696                 LDKRouteHop path_conv_10_conv;
26697                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
26698                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
26699                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
26700                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
26701                 path_constr.data[k] = path_conv_10_conv;
26702         }
26703         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
26704         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26705         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
26706         int64_t ret_ref = tag_ptr(ret_copy, true);
26707         return ret_ref;
26708 }
26709
26710 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_tArray path, int64_t short_channel_id, int64_t retry) {
26711         LDKThirtyTwoBytes payment_id_ref;
26712         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26713         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26714         LDKThirtyTwoBytes payment_hash_ref;
26715         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26716         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26717         void* failure_ptr = untag_ptr(failure);
26718         CHECK_ACCESS(failure_ptr);
26719         LDKPathFailure failure_conv = *(LDKPathFailure*)(failure_ptr);
26720         failure_conv = PathFailure_clone((LDKPathFailure*)untag_ptr(failure));
26721         LDKCVec_RouteHopZ path_constr;
26722         path_constr.datalen = (*env)->GetArrayLength(env, path);
26723         if (path_constr.datalen > 0)
26724                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
26725         else
26726                 path_constr.data = NULL;
26727         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
26728         for (size_t k = 0; k < path_constr.datalen; k++) {
26729                 int64_t path_conv_10 = path_vals[k];
26730                 LDKRouteHop path_conv_10_conv;
26731                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
26732                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
26733                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
26734                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
26735                 path_constr.data[k] = path_conv_10_conv;
26736         }
26737         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
26738         void* short_channel_id_ptr = untag_ptr(short_channel_id);
26739         CHECK_ACCESS(short_channel_id_ptr);
26740         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
26741         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
26742         LDKRouteParameters retry_conv;
26743         retry_conv.inner = untag_ptr(retry);
26744         retry_conv.is_owned = ptr_is_owned(retry);
26745         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
26746         retry_conv = RouteParameters_clone(&retry_conv);
26747         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26748         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, payment_failed_permanently, failure_conv, path_constr, short_channel_id_conv, retry_conv);
26749         int64_t ret_ref = tag_ptr(ret_copy, true);
26750         return ret_ref;
26751 }
26752
26753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1probe_1successful(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_tArray path) {
26754         LDKThirtyTwoBytes payment_id_ref;
26755         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26756         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26757         LDKThirtyTwoBytes payment_hash_ref;
26758         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26759         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26760         LDKCVec_RouteHopZ path_constr;
26761         path_constr.datalen = (*env)->GetArrayLength(env, path);
26762         if (path_constr.datalen > 0)
26763                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
26764         else
26765                 path_constr.data = NULL;
26766         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
26767         for (size_t k = 0; k < path_constr.datalen; k++) {
26768                 int64_t path_conv_10 = path_vals[k];
26769                 LDKRouteHop path_conv_10_conv;
26770                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
26771                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
26772                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
26773                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
26774                 path_constr.data[k] = path_conv_10_conv;
26775         }
26776         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
26777         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26778         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_constr);
26779         int64_t ret_ref = tag_ptr(ret_copy, true);
26780         return ret_ref;
26781 }
26782
26783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1probe_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_tArray path, int64_t short_channel_id) {
26784         LDKThirtyTwoBytes payment_id_ref;
26785         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26786         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26787         LDKThirtyTwoBytes payment_hash_ref;
26788         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26789         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26790         LDKCVec_RouteHopZ path_constr;
26791         path_constr.datalen = (*env)->GetArrayLength(env, path);
26792         if (path_constr.datalen > 0)
26793                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
26794         else
26795                 path_constr.data = NULL;
26796         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
26797         for (size_t k = 0; k < path_constr.datalen; k++) {
26798                 int64_t path_conv_10 = path_vals[k];
26799                 LDKRouteHop path_conv_10_conv;
26800                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
26801                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
26802                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
26803                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
26804                 path_constr.data[k] = path_conv_10_conv;
26805         }
26806         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
26807         void* short_channel_id_ptr = untag_ptr(short_channel_id);
26808         CHECK_ACCESS(short_channel_id_ptr);
26809         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
26810         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
26811         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26812         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_constr, short_channel_id_conv);
26813         int64_t ret_ref = tag_ptr(ret_copy, true);
26814         return ret_ref;
26815 }
26816
26817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
26818         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26819         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
26820         int64_t ret_ref = tag_ptr(ret_copy, true);
26821         return ret_ref;
26822 }
26823
26824 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) {
26825         LDKThirtyTwoBytes intercept_id_ref;
26826         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
26827         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
26828         LDKThirtyTwoBytes payment_hash_ref;
26829         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26830         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26831         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26832         *ret_copy = Event_htlcintercepted(intercept_id_ref, requested_next_hop_scid, payment_hash_ref, inbound_amount_msat, expected_outbound_amount_msat);
26833         int64_t ret_ref = tag_ptr(ret_copy, true);
26834         return ret_ref;
26835 }
26836
26837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
26838         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
26839         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
26840         if (outputs_constr.datalen > 0)
26841                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
26842         else
26843                 outputs_constr.data = NULL;
26844         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
26845         for (size_t b = 0; b < outputs_constr.datalen; b++) {
26846                 int64_t outputs_conv_27 = outputs_vals[b];
26847                 void* outputs_conv_27_ptr = untag_ptr(outputs_conv_27);
26848                 CHECK_ACCESS(outputs_conv_27_ptr);
26849                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
26850                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(outputs_conv_27));
26851                 outputs_constr.data[b] = outputs_conv_27_conv;
26852         }
26853         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
26854         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26855         *ret_copy = Event_spendable_outputs(outputs_constr);
26856         int64_t ret_ref = tag_ptr(ret_copy, true);
26857         return ret_ref;
26858 }
26859
26860 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) {
26861         LDKThirtyTwoBytes prev_channel_id_ref;
26862         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
26863         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
26864         LDKThirtyTwoBytes next_channel_id_ref;
26865         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
26866         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
26867         void* fee_earned_msat_ptr = untag_ptr(fee_earned_msat);
26868         CHECK_ACCESS(fee_earned_msat_ptr);
26869         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
26870         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_earned_msat));
26871         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26872         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
26873         int64_t ret_ref = tag_ptr(ret_copy, true);
26874         return ret_ref;
26875 }
26876
26877 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) {
26878         LDKThirtyTwoBytes channel_id_ref;
26879         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
26880         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
26881         LDKU128 user_channel_id_ref;
26882         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
26883         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
26884         LDKPublicKey counterparty_node_id_ref;
26885         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
26886         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
26887         LDKChannelTypeFeatures channel_type_conv;
26888         channel_type_conv.inner = untag_ptr(channel_type);
26889         channel_type_conv.is_owned = ptr_is_owned(channel_type);
26890         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
26891         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
26892         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26893         *ret_copy = Event_channel_ready(channel_id_ref, user_channel_id_ref, counterparty_node_id_ref, channel_type_conv);
26894         int64_t ret_ref = tag_ptr(ret_copy, true);
26895         return ret_ref;
26896 }
26897
26898 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) {
26899         LDKThirtyTwoBytes channel_id_ref;
26900         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
26901         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
26902         LDKU128 user_channel_id_ref;
26903         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
26904         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
26905         void* reason_ptr = untag_ptr(reason);
26906         CHECK_ACCESS(reason_ptr);
26907         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
26908         reason_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(reason));
26909         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26910         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id_ref, reason_conv);
26911         int64_t ret_ref = tag_ptr(ret_copy, true);
26912         return ret_ref;
26913 }
26914
26915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
26916         LDKThirtyTwoBytes channel_id_ref;
26917         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
26918         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
26919         LDKTransaction transaction_ref;
26920         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
26921         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
26922         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
26923         transaction_ref.data_is_owned = true;
26924         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26925         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
26926         int64_t ret_ref = tag_ptr(ret_copy, true);
26927         return ret_ref;
26928 }
26929
26930 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) {
26931         LDKThirtyTwoBytes temporary_channel_id_ref;
26932         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
26933         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
26934         LDKPublicKey counterparty_node_id_ref;
26935         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
26936         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
26937         LDKChannelTypeFeatures channel_type_conv;
26938         channel_type_conv.inner = untag_ptr(channel_type);
26939         channel_type_conv.is_owned = ptr_is_owned(channel_type);
26940         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
26941         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
26942         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26943         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
26944         int64_t ret_ref = tag_ptr(ret_copy, true);
26945         return ret_ref;
26946 }
26947
26948 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) {
26949         LDKThirtyTwoBytes prev_channel_id_ref;
26950         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
26951         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
26952         void* failed_next_destination_ptr = untag_ptr(failed_next_destination);
26953         CHECK_ACCESS(failed_next_destination_ptr);
26954         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
26955         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(failed_next_destination));
26956         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26957         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
26958         int64_t ret_ref = tag_ptr(ret_copy, true);
26959         return ret_ref;
26960 }
26961
26962 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Event_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26963         LDKEvent* a_conv = (LDKEvent*)untag_ptr(a);
26964         LDKEvent* b_conv = (LDKEvent*)untag_ptr(b);
26965         jboolean ret_conv = Event_eq(a_conv, b_conv);
26966         return ret_conv;
26967 }
26968
26969 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
26970         LDKEvent* obj_conv = (LDKEvent*)untag_ptr(obj);
26971         LDKCVec_u8Z ret_var = Event_write(obj_conv);
26972         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26973         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26974         CVec_u8Z_free(ret_var);
26975         return ret_arr;
26976 }
26977
26978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26979         LDKu8slice ser_ref;
26980         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26981         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26982         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
26983         *ret_conv = Event_read(ser_ref);
26984         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26985         return tag_ptr(ret_conv, true);
26986 }
26987
26988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26989         if (!ptr_is_owned(this_ptr)) return;
26990         void* this_ptr_ptr = untag_ptr(this_ptr);
26991         CHECK_ACCESS(this_ptr_ptr);
26992         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
26993         FREE(untag_ptr(this_ptr));
26994         MessageSendEvent_free(this_ptr_conv);
26995 }
26996
26997 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
26998         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26999         *ret_copy = MessageSendEvent_clone(arg);
27000         int64_t ret_ref = tag_ptr(ret_copy, true);
27001         return ret_ref;
27002 }
27003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27004         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)untag_ptr(arg);
27005         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
27006         return ret_conv;
27007 }
27008
27009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27010         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)untag_ptr(orig);
27011         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27012         *ret_copy = MessageSendEvent_clone(orig_conv);
27013         int64_t ret_ref = tag_ptr(ret_copy, true);
27014         return ret_ref;
27015 }
27016
27017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
27018         LDKPublicKey node_id_ref;
27019         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27020         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27021         LDKAcceptChannel msg_conv;
27022         msg_conv.inner = untag_ptr(msg);
27023         msg_conv.is_owned = ptr_is_owned(msg);
27024         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27025         msg_conv = AcceptChannel_clone(&msg_conv);
27026         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27027         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
27028         int64_t ret_ref = tag_ptr(ret_copy, true);
27029         return ret_ref;
27030 }
27031
27032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
27033         LDKPublicKey node_id_ref;
27034         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27035         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27036         LDKOpenChannel msg_conv;
27037         msg_conv.inner = untag_ptr(msg);
27038         msg_conv.is_owned = ptr_is_owned(msg);
27039         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27040         msg_conv = OpenChannel_clone(&msg_conv);
27041         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27042         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
27043         int64_t ret_ref = tag_ptr(ret_copy, true);
27044         return ret_ref;
27045 }
27046
27047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
27048         LDKPublicKey node_id_ref;
27049         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27050         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27051         LDKFundingCreated msg_conv;
27052         msg_conv.inner = untag_ptr(msg);
27053         msg_conv.is_owned = ptr_is_owned(msg);
27054         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27055         msg_conv = FundingCreated_clone(&msg_conv);
27056         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27057         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
27058         int64_t ret_ref = tag_ptr(ret_copy, true);
27059         return ret_ref;
27060 }
27061
27062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
27063         LDKPublicKey node_id_ref;
27064         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27065         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27066         LDKFundingSigned msg_conv;
27067         msg_conv.inner = untag_ptr(msg);
27068         msg_conv.is_owned = ptr_is_owned(msg);
27069         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27070         msg_conv = FundingSigned_clone(&msg_conv);
27071         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27072         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
27073         int64_t ret_ref = tag_ptr(ret_copy, true);
27074         return ret_ref;
27075 }
27076
27077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
27078         LDKPublicKey node_id_ref;
27079         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27080         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27081         LDKChannelReady msg_conv;
27082         msg_conv.inner = untag_ptr(msg);
27083         msg_conv.is_owned = ptr_is_owned(msg);
27084         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27085         msg_conv = ChannelReady_clone(&msg_conv);
27086         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27087         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
27088         int64_t ret_ref = tag_ptr(ret_copy, true);
27089         return ret_ref;
27090 }
27091
27092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
27093         LDKPublicKey node_id_ref;
27094         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27095         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27096         LDKAnnouncementSignatures msg_conv;
27097         msg_conv.inner = untag_ptr(msg);
27098         msg_conv.is_owned = ptr_is_owned(msg);
27099         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27100         msg_conv = AnnouncementSignatures_clone(&msg_conv);
27101         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27102         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
27103         int64_t ret_ref = tag_ptr(ret_copy, true);
27104         return ret_ref;
27105 }
27106
27107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
27108         LDKPublicKey node_id_ref;
27109         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27110         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27111         LDKCommitmentUpdate updates_conv;
27112         updates_conv.inner = untag_ptr(updates);
27113         updates_conv.is_owned = ptr_is_owned(updates);
27114         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
27115         updates_conv = CommitmentUpdate_clone(&updates_conv);
27116         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27117         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
27118         int64_t ret_ref = tag_ptr(ret_copy, true);
27119         return ret_ref;
27120 }
27121
27122 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) {
27123         LDKPublicKey node_id_ref;
27124         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27125         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27126         LDKRevokeAndACK msg_conv;
27127         msg_conv.inner = untag_ptr(msg);
27128         msg_conv.is_owned = ptr_is_owned(msg);
27129         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27130         msg_conv = RevokeAndACK_clone(&msg_conv);
27131         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27132         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
27133         int64_t ret_ref = tag_ptr(ret_copy, true);
27134         return ret_ref;
27135 }
27136
27137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
27138         LDKPublicKey node_id_ref;
27139         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27140         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27141         LDKClosingSigned msg_conv;
27142         msg_conv.inner = untag_ptr(msg);
27143         msg_conv.is_owned = ptr_is_owned(msg);
27144         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27145         msg_conv = ClosingSigned_clone(&msg_conv);
27146         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27147         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
27148         int64_t ret_ref = tag_ptr(ret_copy, true);
27149         return ret_ref;
27150 }
27151
27152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
27153         LDKPublicKey node_id_ref;
27154         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27155         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27156         LDKShutdown msg_conv;
27157         msg_conv.inner = untag_ptr(msg);
27158         msg_conv.is_owned = ptr_is_owned(msg);
27159         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27160         msg_conv = Shutdown_clone(&msg_conv);
27161         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27162         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
27163         int64_t ret_ref = tag_ptr(ret_copy, true);
27164         return ret_ref;
27165 }
27166
27167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
27168         LDKPublicKey node_id_ref;
27169         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27170         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27171         LDKChannelReestablish msg_conv;
27172         msg_conv.inner = untag_ptr(msg);
27173         msg_conv.is_owned = ptr_is_owned(msg);
27174         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27175         msg_conv = ChannelReestablish_clone(&msg_conv);
27176         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27177         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
27178         int64_t ret_ref = tag_ptr(ret_copy, true);
27179         return ret_ref;
27180 }
27181
27182 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) {
27183         LDKPublicKey node_id_ref;
27184         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27185         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27186         LDKChannelAnnouncement msg_conv;
27187         msg_conv.inner = untag_ptr(msg);
27188         msg_conv.is_owned = ptr_is_owned(msg);
27189         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27190         msg_conv = ChannelAnnouncement_clone(&msg_conv);
27191         LDKChannelUpdate update_msg_conv;
27192         update_msg_conv.inner = untag_ptr(update_msg);
27193         update_msg_conv.is_owned = ptr_is_owned(update_msg);
27194         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
27195         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
27196         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27197         *ret_copy = MessageSendEvent_send_channel_announcement(node_id_ref, msg_conv, update_msg_conv);
27198         int64_t ret_ref = tag_ptr(ret_copy, true);
27199         return ret_ref;
27200 }
27201
27202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
27203         LDKChannelAnnouncement msg_conv;
27204         msg_conv.inner = untag_ptr(msg);
27205         msg_conv.is_owned = ptr_is_owned(msg);
27206         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27207         msg_conv = ChannelAnnouncement_clone(&msg_conv);
27208         LDKChannelUpdate update_msg_conv;
27209         update_msg_conv.inner = untag_ptr(update_msg);
27210         update_msg_conv.is_owned = ptr_is_owned(update_msg);
27211         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
27212         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
27213         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27214         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
27215         int64_t ret_ref = tag_ptr(ret_copy, true);
27216         return ret_ref;
27217 }
27218
27219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
27220         LDKChannelUpdate msg_conv;
27221         msg_conv.inner = untag_ptr(msg);
27222         msg_conv.is_owned = ptr_is_owned(msg);
27223         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27224         msg_conv = ChannelUpdate_clone(&msg_conv);
27225         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27226         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
27227         int64_t ret_ref = tag_ptr(ret_copy, true);
27228         return ret_ref;
27229 }
27230
27231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
27232         LDKNodeAnnouncement msg_conv;
27233         msg_conv.inner = untag_ptr(msg);
27234         msg_conv.is_owned = ptr_is_owned(msg);
27235         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27236         msg_conv = NodeAnnouncement_clone(&msg_conv);
27237         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27238         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
27239         int64_t ret_ref = tag_ptr(ret_copy, true);
27240         return ret_ref;
27241 }
27242
27243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
27244         LDKPublicKey node_id_ref;
27245         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27246         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27247         LDKChannelUpdate msg_conv;
27248         msg_conv.inner = untag_ptr(msg);
27249         msg_conv.is_owned = ptr_is_owned(msg);
27250         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27251         msg_conv = ChannelUpdate_clone(&msg_conv);
27252         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27253         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
27254         int64_t ret_ref = tag_ptr(ret_copy, true);
27255         return ret_ref;
27256 }
27257
27258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
27259         LDKPublicKey node_id_ref;
27260         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27261         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27262         void* action_ptr = untag_ptr(action);
27263         CHECK_ACCESS(action_ptr);
27264         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
27265         action_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action));
27266         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27267         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
27268         int64_t ret_ref = tag_ptr(ret_copy, true);
27269         return ret_ref;
27270 }
27271
27272 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) {
27273         LDKPublicKey node_id_ref;
27274         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27275         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27276         LDKQueryChannelRange msg_conv;
27277         msg_conv.inner = untag_ptr(msg);
27278         msg_conv.is_owned = ptr_is_owned(msg);
27279         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27280         msg_conv = QueryChannelRange_clone(&msg_conv);
27281         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27282         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
27283         int64_t ret_ref = tag_ptr(ret_copy, true);
27284         return ret_ref;
27285 }
27286
27287 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) {
27288         LDKPublicKey node_id_ref;
27289         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27290         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27291         LDKQueryShortChannelIds msg_conv;
27292         msg_conv.inner = untag_ptr(msg);
27293         msg_conv.is_owned = ptr_is_owned(msg);
27294         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27295         msg_conv = QueryShortChannelIds_clone(&msg_conv);
27296         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27297         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
27298         int64_t ret_ref = tag_ptr(ret_copy, true);
27299         return ret_ref;
27300 }
27301
27302 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) {
27303         LDKPublicKey node_id_ref;
27304         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27305         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27306         LDKReplyChannelRange msg_conv;
27307         msg_conv.inner = untag_ptr(msg);
27308         msg_conv.is_owned = ptr_is_owned(msg);
27309         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27310         msg_conv = ReplyChannelRange_clone(&msg_conv);
27311         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27312         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
27313         int64_t ret_ref = tag_ptr(ret_copy, true);
27314         return ret_ref;
27315 }
27316
27317 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) {
27318         LDKPublicKey node_id_ref;
27319         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27320         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27321         LDKGossipTimestampFilter msg_conv;
27322         msg_conv.inner = untag_ptr(msg);
27323         msg_conv.is_owned = ptr_is_owned(msg);
27324         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27325         msg_conv = GossipTimestampFilter_clone(&msg_conv);
27326         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
27327         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
27328         int64_t ret_ref = tag_ptr(ret_copy, true);
27329         return ret_ref;
27330 }
27331
27332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27333         if (!ptr_is_owned(this_ptr)) return;
27334         void* this_ptr_ptr = untag_ptr(this_ptr);
27335         CHECK_ACCESS(this_ptr_ptr);
27336         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
27337         FREE(untag_ptr(this_ptr));
27338         MessageSendEventsProvider_free(this_ptr_conv);
27339 }
27340
27341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27342         if (!ptr_is_owned(this_ptr)) return;
27343         void* this_ptr_ptr = untag_ptr(this_ptr);
27344         CHECK_ACCESS(this_ptr_ptr);
27345         LDKOnionMessageProvider this_ptr_conv = *(LDKOnionMessageProvider*)(this_ptr_ptr);
27346         FREE(untag_ptr(this_ptr));
27347         OnionMessageProvider_free(this_ptr_conv);
27348 }
27349
27350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27351         if (!ptr_is_owned(this_ptr)) return;
27352         void* this_ptr_ptr = untag_ptr(this_ptr);
27353         CHECK_ACCESS(this_ptr_ptr);
27354         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
27355         FREE(untag_ptr(this_ptr));
27356         EventsProvider_free(this_ptr_conv);
27357 }
27358
27359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27360         if (!ptr_is_owned(this_ptr)) return;
27361         void* this_ptr_ptr = untag_ptr(this_ptr);
27362         CHECK_ACCESS(this_ptr_ptr);
27363         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
27364         FREE(untag_ptr(this_ptr));
27365         EventHandler_free(this_ptr_conv);
27366 }
27367
27368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27369         if (!ptr_is_owned(this_ptr)) return;
27370         void* this_ptr_ptr = untag_ptr(this_ptr);
27371         CHECK_ACCESS(this_ptr_ptr);
27372         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
27373         FREE(untag_ptr(this_ptr));
27374         APIError_free(this_ptr_conv);
27375 }
27376
27377 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
27378         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27379         *ret_copy = APIError_clone(arg);
27380         int64_t ret_ref = tag_ptr(ret_copy, true);
27381         return ret_ref;
27382 }
27383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27384         LDKAPIError* arg_conv = (LDKAPIError*)untag_ptr(arg);
27385         int64_t ret_conv = APIError_clone_ptr(arg_conv);
27386         return ret_conv;
27387 }
27388
27389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27390         LDKAPIError* orig_conv = (LDKAPIError*)untag_ptr(orig);
27391         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27392         *ret_copy = APIError_clone(orig_conv);
27393         int64_t ret_ref = tag_ptr(ret_copy, true);
27394         return ret_ref;
27395 }
27396
27397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
27398         LDKStr err_conv = java_to_owned_str(env, err);
27399         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27400         *ret_copy = APIError_apimisuse_error(err_conv);
27401         int64_t ret_ref = tag_ptr(ret_copy, true);
27402         return ret_ref;
27403 }
27404
27405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
27406         LDKStr err_conv = java_to_owned_str(env, err);
27407         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27408         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
27409         int64_t ret_ref = tag_ptr(ret_copy, true);
27410         return ret_ref;
27411 }
27412
27413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1invalid_1route(JNIEnv *env, jclass clz, jstring err) {
27414         LDKStr err_conv = java_to_owned_str(env, err);
27415         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27416         *ret_copy = APIError_invalid_route(err_conv);
27417         int64_t ret_ref = tag_ptr(ret_copy, true);
27418         return ret_ref;
27419 }
27420
27421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
27422         LDKStr err_conv = java_to_owned_str(env, err);
27423         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27424         *ret_copy = APIError_channel_unavailable(err_conv);
27425         int64_t ret_ref = tag_ptr(ret_copy, true);
27426         return ret_ref;
27427 }
27428
27429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1in_1progress(JNIEnv *env, jclass clz) {
27430         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27431         *ret_copy = APIError_monitor_update_in_progress();
27432         int64_t ret_ref = tag_ptr(ret_copy, true);
27433         return ret_ref;
27434 }
27435
27436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
27437         LDKShutdownScript script_conv;
27438         script_conv.inner = untag_ptr(script);
27439         script_conv.is_owned = ptr_is_owned(script);
27440         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
27441         script_conv = ShutdownScript_clone(&script_conv);
27442         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27443         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
27444         int64_t ret_ref = tag_ptr(ret_copy, true);
27445         return ret_ref;
27446 }
27447
27448 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_APIError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27449         LDKAPIError* a_conv = (LDKAPIError*)untag_ptr(a);
27450         LDKAPIError* b_conv = (LDKAPIError*)untag_ptr(b);
27451         jboolean ret_conv = APIError_eq(a_conv, b_conv);
27452         return ret_conv;
27453 }
27454
27455 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_APIError_1write(JNIEnv *env, jclass clz, int64_t obj) {
27456         LDKAPIError* obj_conv = (LDKAPIError*)untag_ptr(obj);
27457         LDKCVec_u8Z ret_var = APIError_write(obj_conv);
27458         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27459         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27460         CVec_u8Z_free(ret_var);
27461         return ret_arr;
27462 }
27463
27464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27465         LDKu8slice ser_ref;
27466         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27467         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27468         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
27469         *ret_conv = APIError_read(ser_ref);
27470         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27471         return tag_ptr(ret_conv, true);
27472 }
27473
27474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27475         LDKBigSize this_obj_conv;
27476         this_obj_conv.inner = untag_ptr(this_obj);
27477         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27479         BigSize_free(this_obj_conv);
27480 }
27481
27482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27483         LDKBigSize this_ptr_conv;
27484         this_ptr_conv.inner = untag_ptr(this_ptr);
27485         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27487         this_ptr_conv.is_owned = false;
27488         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
27489         return ret_conv;
27490 }
27491
27492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27493         LDKBigSize this_ptr_conv;
27494         this_ptr_conv.inner = untag_ptr(this_ptr);
27495         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27497         this_ptr_conv.is_owned = false;
27498         BigSize_set_a(&this_ptr_conv, val);
27499 }
27500
27501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
27502         LDKBigSize ret_var = BigSize_new(a_arg);
27503         int64_t ret_ref = 0;
27504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27505         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27506         return ret_ref;
27507 }
27508
27509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hostname_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27510         LDKHostname this_obj_conv;
27511         this_obj_conv.inner = untag_ptr(this_obj);
27512         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27514         Hostname_free(this_obj_conv);
27515 }
27516
27517 static inline uint64_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
27518         LDKHostname ret_var = Hostname_clone(arg);
27519         int64_t ret_ref = 0;
27520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27521         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27522         return ret_ref;
27523 }
27524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27525         LDKHostname arg_conv;
27526         arg_conv.inner = untag_ptr(arg);
27527         arg_conv.is_owned = ptr_is_owned(arg);
27528         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27529         arg_conv.is_owned = false;
27530         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
27531         return ret_conv;
27532 }
27533
27534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27535         LDKHostname orig_conv;
27536         orig_conv.inner = untag_ptr(orig);
27537         orig_conv.is_owned = ptr_is_owned(orig);
27538         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27539         orig_conv.is_owned = false;
27540         LDKHostname ret_var = Hostname_clone(&orig_conv);
27541         int64_t ret_ref = 0;
27542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27543         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27544         return ret_ref;
27545 }
27546
27547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Hostname_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27548         LDKHostname a_conv;
27549         a_conv.inner = untag_ptr(a);
27550         a_conv.is_owned = ptr_is_owned(a);
27551         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27552         a_conv.is_owned = false;
27553         LDKHostname b_conv;
27554         b_conv.inner = untag_ptr(b);
27555         b_conv.is_owned = ptr_is_owned(b);
27556         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27557         b_conv.is_owned = false;
27558         jboolean ret_conv = Hostname_eq(&a_conv, &b_conv);
27559         return ret_conv;
27560 }
27561
27562 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_Hostname_1len(JNIEnv *env, jclass clz, int64_t this_arg) {
27563         LDKHostname this_arg_conv;
27564         this_arg_conv.inner = untag_ptr(this_arg);
27565         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27567         this_arg_conv.is_owned = false;
27568         int8_t ret_conv = Hostname_len(&this_arg_conv);
27569         return ret_conv;
27570 }
27571
27572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
27573         LDKu8slice msg_ref;
27574         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27575         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27576         uint8_t sk_arr[32];
27577         CHECK((*env)->GetArrayLength(env, sk) == 32);
27578         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
27579         uint8_t (*sk_ref)[32] = &sk_arr;
27580         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
27581         *ret_conv = sign(msg_ref, sk_ref);
27582         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27583         return tag_ptr(ret_conv, true);
27584 }
27585
27586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
27587         LDKu8slice msg_ref;
27588         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27589         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27590         LDKStr sig_conv = java_to_owned_str(env, sig);
27591         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
27592         *ret_conv = recover_pk(msg_ref, sig_conv);
27593         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27594         return tag_ptr(ret_conv, true);
27595 }
27596
27597 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
27598         LDKu8slice msg_ref;
27599         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27600         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27601         LDKStr sig_conv = java_to_owned_str(env, sig);
27602         LDKPublicKey pk_ref;
27603         CHECK((*env)->GetArrayLength(env, pk) == 33);
27604         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
27605         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
27606         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27607         return ret_conv;
27608 }
27609
27610 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
27611         LDKu8slice hrp_bytes_ref;
27612         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
27613         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
27614         LDKCVec_U5Z data_without_signature_constr;
27615         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
27616         if (data_without_signature_constr.datalen > 0)
27617                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
27618         else
27619                 data_without_signature_constr.data = NULL;
27620         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
27621         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
27622                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
27623                 
27624                 data_without_signature_constr.data[h] = (LDKU5){ ._0 = data_without_signature_conv_7 };
27625         }
27626         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
27627         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
27628         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27629         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27630         CVec_u8Z_free(ret_var);
27631         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
27632         return ret_arr;
27633 }
27634
27635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27636         if (!ptr_is_owned(this_ptr)) return;
27637         void* this_ptr_ptr = untag_ptr(this_ptr);
27638         CHECK_ACCESS(this_ptr_ptr);
27639         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
27640         FREE(untag_ptr(this_ptr));
27641         Persister_free(this_ptr_conv);
27642 }
27643
27644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrintableString_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27645         LDKPrintableString this_obj_conv;
27646         this_obj_conv.inner = untag_ptr(this_obj);
27647         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27649         PrintableString_free(this_obj_conv);
27650 }
27651
27652 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_PrintableString_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27653         LDKPrintableString this_ptr_conv;
27654         this_ptr_conv.inner = untag_ptr(this_ptr);
27655         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27657         this_ptr_conv.is_owned = false;
27658         LDKStr ret_str = PrintableString_get_a(&this_ptr_conv);
27659         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27660         Str_free(ret_str);
27661         return ret_conv;
27662 }
27663
27664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrintableString_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27665         LDKPrintableString this_ptr_conv;
27666         this_ptr_conv.inner = untag_ptr(this_ptr);
27667         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27669         this_ptr_conv.is_owned = false;
27670         LDKStr val_conv = java_to_owned_str(env, val);
27671         PrintableString_set_a(&this_ptr_conv, val_conv);
27672 }
27673
27674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrintableString_1new(JNIEnv *env, jclass clz, jstring a_arg) {
27675         LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
27676         LDKPrintableString ret_var = PrintableString_new(a_arg_conv);
27677         int64_t ret_ref = 0;
27678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27679         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27680         return ret_ref;
27681 }
27682
27683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27684         if (!ptr_is_owned(this_ptr)) return;
27685         void* this_ptr_ptr = untag_ptr(this_ptr);
27686         CHECK_ACCESS(this_ptr_ptr);
27687         LDKFutureCallback this_ptr_conv = *(LDKFutureCallback*)(this_ptr_ptr);
27688         FREE(untag_ptr(this_ptr));
27689         FutureCallback_free(this_ptr_conv);
27690 }
27691
27692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27693         LDKFuture this_obj_conv;
27694         this_obj_conv.inner = untag_ptr(this_obj);
27695         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27697         Future_free(this_obj_conv);
27698 }
27699
27700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1register_1callback_1fn(JNIEnv *env, jclass clz, int64_t this_arg, int64_t callback) {
27701         LDKFuture this_arg_conv;
27702         this_arg_conv.inner = untag_ptr(this_arg);
27703         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27705         this_arg_conv.is_owned = false;
27706         void* callback_ptr = untag_ptr(callback);
27707         CHECK_ACCESS(callback_ptr);
27708         LDKFutureCallback callback_conv = *(LDKFutureCallback*)(callback_ptr);
27709         if (callback_conv.free == LDKFutureCallback_JCalls_free) {
27710                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27711                 LDKFutureCallback_JCalls_cloned(&callback_conv);
27712         }
27713         Future_register_callback_fn(&this_arg_conv, callback_conv);
27714 }
27715
27716 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27717         LDKLevel* orig_conv = (LDKLevel*)untag_ptr(orig);
27718         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
27719         return ret_conv;
27720 }
27721
27722 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
27723         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
27724         return ret_conv;
27725 }
27726
27727 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
27728         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
27729         return ret_conv;
27730 }
27731
27732 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
27733         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
27734         return ret_conv;
27735 }
27736
27737 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
27738         jclass ret_conv = LDKLevel_to_java(env, Level_info());
27739         return ret_conv;
27740 }
27741
27742 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
27743         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
27744         return ret_conv;
27745 }
27746
27747 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
27748         jclass ret_conv = LDKLevel_to_java(env, Level_error());
27749         return ret_conv;
27750 }
27751
27752 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27753         LDKLevel* a_conv = (LDKLevel*)untag_ptr(a);
27754         LDKLevel* b_conv = (LDKLevel*)untag_ptr(b);
27755         jboolean ret_conv = Level_eq(a_conv, b_conv);
27756         return ret_conv;
27757 }
27758
27759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
27760         LDKLevel* o_conv = (LDKLevel*)untag_ptr(o);
27761         int64_t ret_conv = Level_hash(o_conv);
27762         return ret_conv;
27763 }
27764
27765 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
27766         jclass ret_conv = LDKLevel_to_java(env, Level_max());
27767         return ret_conv;
27768 }
27769
27770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27771         LDKRecord this_obj_conv;
27772         this_obj_conv.inner = untag_ptr(this_obj);
27773         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27775         Record_free(this_obj_conv);
27776 }
27777
27778 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
27779         LDKRecord this_ptr_conv;
27780         this_ptr_conv.inner = untag_ptr(this_ptr);
27781         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27783         this_ptr_conv.is_owned = false;
27784         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
27785         return ret_conv;
27786 }
27787
27788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
27789         LDKRecord this_ptr_conv;
27790         this_ptr_conv.inner = untag_ptr(this_ptr);
27791         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27793         this_ptr_conv.is_owned = false;
27794         LDKLevel val_conv = LDKLevel_from_java(env, val);
27795         Record_set_level(&this_ptr_conv, val_conv);
27796 }
27797
27798 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
27799         LDKRecord this_ptr_conv;
27800         this_ptr_conv.inner = untag_ptr(this_ptr);
27801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27803         this_ptr_conv.is_owned = false;
27804         LDKStr ret_str = Record_get_args(&this_ptr_conv);
27805         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27806         Str_free(ret_str);
27807         return ret_conv;
27808 }
27809
27810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27811         LDKRecord this_ptr_conv;
27812         this_ptr_conv.inner = untag_ptr(this_ptr);
27813         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27815         this_ptr_conv.is_owned = false;
27816         LDKStr val_conv = java_to_owned_str(env, val);
27817         Record_set_args(&this_ptr_conv, val_conv);
27818 }
27819
27820 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
27821         LDKRecord this_ptr_conv;
27822         this_ptr_conv.inner = untag_ptr(this_ptr);
27823         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27825         this_ptr_conv.is_owned = false;
27826         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
27827         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27828         Str_free(ret_str);
27829         return ret_conv;
27830 }
27831
27832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27833         LDKRecord this_ptr_conv;
27834         this_ptr_conv.inner = untag_ptr(this_ptr);
27835         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27837         this_ptr_conv.is_owned = false;
27838         LDKStr val_conv = java_to_owned_str(env, val);
27839         Record_set_module_path(&this_ptr_conv, val_conv);
27840 }
27841
27842 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
27843         LDKRecord this_ptr_conv;
27844         this_ptr_conv.inner = untag_ptr(this_ptr);
27845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27847         this_ptr_conv.is_owned = false;
27848         LDKStr ret_str = Record_get_file(&this_ptr_conv);
27849         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27850         Str_free(ret_str);
27851         return ret_conv;
27852 }
27853
27854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27855         LDKRecord this_ptr_conv;
27856         this_ptr_conv.inner = untag_ptr(this_ptr);
27857         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27859         this_ptr_conv.is_owned = false;
27860         LDKStr val_conv = java_to_owned_str(env, val);
27861         Record_set_file(&this_ptr_conv, val_conv);
27862 }
27863
27864 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
27865         LDKRecord 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         int32_t ret_conv = Record_get_line(&this_ptr_conv);
27871         return ret_conv;
27872 }
27873
27874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27875         LDKRecord 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         Record_set_line(&this_ptr_conv, val);
27881 }
27882
27883 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
27884         LDKRecord ret_var = Record_clone(arg);
27885         int64_t ret_ref = 0;
27886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27887         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27888         return ret_ref;
27889 }
27890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27891         LDKRecord arg_conv;
27892         arg_conv.inner = untag_ptr(arg);
27893         arg_conv.is_owned = ptr_is_owned(arg);
27894         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27895         arg_conv.is_owned = false;
27896         int64_t ret_conv = Record_clone_ptr(&arg_conv);
27897         return ret_conv;
27898 }
27899
27900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27901         LDKRecord orig_conv;
27902         orig_conv.inner = untag_ptr(orig);
27903         orig_conv.is_owned = ptr_is_owned(orig);
27904         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27905         orig_conv.is_owned = false;
27906         LDKRecord ret_var = Record_clone(&orig_conv);
27907         int64_t ret_ref = 0;
27908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27910         return ret_ref;
27911 }
27912
27913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27914         if (!ptr_is_owned(this_ptr)) return;
27915         void* this_ptr_ptr = untag_ptr(this_ptr);
27916         CHECK_ACCESS(this_ptr_ptr);
27917         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
27918         FREE(untag_ptr(this_ptr));
27919         Logger_free(this_ptr_conv);
27920 }
27921
27922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27923         LDKChannelHandshakeConfig this_obj_conv;
27924         this_obj_conv.inner = untag_ptr(this_obj);
27925         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27927         ChannelHandshakeConfig_free(this_obj_conv);
27928 }
27929
27930 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
27931         LDKChannelHandshakeConfig this_ptr_conv;
27932         this_ptr_conv.inner = untag_ptr(this_ptr);
27933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27935         this_ptr_conv.is_owned = false;
27936         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
27937         return ret_conv;
27938 }
27939
27940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
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         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
27947 }
27948
27949 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27950         LDKChannelHandshakeConfig this_ptr_conv;
27951         this_ptr_conv.inner = untag_ptr(this_ptr);
27952         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27954         this_ptr_conv.is_owned = false;
27955         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
27956         return ret_conv;
27957 }
27958
27959 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) {
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         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
27966 }
27967
27968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27969         LDKChannelHandshakeConfig this_ptr_conv;
27970         this_ptr_conv.inner = untag_ptr(this_ptr);
27971         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27973         this_ptr_conv.is_owned = false;
27974         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
27975         return ret_conv;
27976 }
27977
27978 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) {
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         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
27985 }
27986
27987 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) {
27988         LDKChannelHandshakeConfig this_ptr_conv;
27989         this_ptr_conv.inner = untag_ptr(this_ptr);
27990         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27992         this_ptr_conv.is_owned = false;
27993         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
27994         return ret_conv;
27995 }
27996
27997 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) {
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         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
28004 }
28005
28006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
28007         LDKChannelHandshakeConfig this_ptr_conv;
28008         this_ptr_conv.inner = untag_ptr(this_ptr);
28009         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28011         this_ptr_conv.is_owned = false;
28012         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
28013         return ret_conv;
28014 }
28015
28016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28017         LDKChannelHandshakeConfig this_ptr_conv;
28018         this_ptr_conv.inner = untag_ptr(this_ptr);
28019         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28021         this_ptr_conv.is_owned = false;
28022         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
28023 }
28024
28025 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
28026         LDKChannelHandshakeConfig this_ptr_conv;
28027         this_ptr_conv.inner = untag_ptr(this_ptr);
28028         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28030         this_ptr_conv.is_owned = false;
28031         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
28032         return ret_conv;
28033 }
28034
28035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28036         LDKChannelHandshakeConfig this_ptr_conv;
28037         this_ptr_conv.inner = untag_ptr(this_ptr);
28038         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28040         this_ptr_conv.is_owned = false;
28041         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
28042 }
28043
28044 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28045         LDKChannelHandshakeConfig this_ptr_conv;
28046         this_ptr_conv.inner = untag_ptr(this_ptr);
28047         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28049         this_ptr_conv.is_owned = false;
28050         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
28051         return ret_conv;
28052 }
28053
28054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28055         LDKChannelHandshakeConfig this_ptr_conv;
28056         this_ptr_conv.inner = untag_ptr(this_ptr);
28057         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28059         this_ptr_conv.is_owned = false;
28060         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
28061 }
28062
28063 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1their_1channel_1reserve_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
28064         LDKChannelHandshakeConfig this_ptr_conv;
28065         this_ptr_conv.inner = untag_ptr(this_ptr);
28066         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28068         this_ptr_conv.is_owned = false;
28069         int32_t ret_conv = ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(&this_ptr_conv);
28070         return ret_conv;
28071 }
28072
28073 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) {
28074         LDKChannelHandshakeConfig this_ptr_conv;
28075         this_ptr_conv.inner = untag_ptr(this_ptr);
28076         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28078         this_ptr_conv.is_owned = false;
28079         ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(&this_ptr_conv, val);
28080 }
28081
28082 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) {
28083         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);
28084         int64_t ret_ref = 0;
28085         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28086         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28087         return ret_ref;
28088 }
28089
28090 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
28091         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
28092         int64_t ret_ref = 0;
28093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28094         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28095         return ret_ref;
28096 }
28097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28098         LDKChannelHandshakeConfig arg_conv;
28099         arg_conv.inner = untag_ptr(arg);
28100         arg_conv.is_owned = ptr_is_owned(arg);
28101         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28102         arg_conv.is_owned = false;
28103         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
28104         return ret_conv;
28105 }
28106
28107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28108         LDKChannelHandshakeConfig orig_conv;
28109         orig_conv.inner = untag_ptr(orig);
28110         orig_conv.is_owned = ptr_is_owned(orig);
28111         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28112         orig_conv.is_owned = false;
28113         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
28114         int64_t ret_ref = 0;
28115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28116         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28117         return ret_ref;
28118 }
28119
28120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
28121         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
28122         int64_t ret_ref = 0;
28123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28124         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28125         return ret_ref;
28126 }
28127
28128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28129         LDKChannelHandshakeLimits this_obj_conv;
28130         this_obj_conv.inner = untag_ptr(this_obj);
28131         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28133         ChannelHandshakeLimits_free(this_obj_conv);
28134 }
28135
28136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28137         LDKChannelHandshakeLimits this_ptr_conv;
28138         this_ptr_conv.inner = untag_ptr(this_ptr);
28139         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28141         this_ptr_conv.is_owned = false;
28142         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
28143         return ret_conv;
28144 }
28145
28146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
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         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
28153 }
28154
28155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28156         LDKChannelHandshakeLimits this_ptr_conv;
28157         this_ptr_conv.inner = untag_ptr(this_ptr);
28158         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28160         this_ptr_conv.is_owned = false;
28161         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
28162         return ret_conv;
28163 }
28164
28165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
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         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
28172 }
28173
28174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28175         LDKChannelHandshakeLimits this_ptr_conv;
28176         this_ptr_conv.inner = untag_ptr(this_ptr);
28177         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28179         this_ptr_conv.is_owned = false;
28180         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
28181         return ret_conv;
28182 }
28183
28184 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) {
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         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
28191 }
28192
28193 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) {
28194         LDKChannelHandshakeLimits this_ptr_conv;
28195         this_ptr_conv.inner = untag_ptr(this_ptr);
28196         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28198         this_ptr_conv.is_owned = false;
28199         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
28200         return ret_conv;
28201 }
28202
28203 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) {
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         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28210 }
28211
28212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28213         LDKChannelHandshakeLimits this_ptr_conv;
28214         this_ptr_conv.inner = untag_ptr(this_ptr);
28215         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28217         this_ptr_conv.is_owned = false;
28218         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
28219         return ret_conv;
28220 }
28221
28222 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) {
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         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
28229 }
28230
28231 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28232         LDKChannelHandshakeLimits this_ptr_conv;
28233         this_ptr_conv.inner = untag_ptr(this_ptr);
28234         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28236         this_ptr_conv.is_owned = false;
28237         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
28238         return ret_conv;
28239 }
28240
28241 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) {
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         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
28248 }
28249
28250 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
28251         LDKChannelHandshakeLimits this_ptr_conv;
28252         this_ptr_conv.inner = untag_ptr(this_ptr);
28253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28255         this_ptr_conv.is_owned = false;
28256         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
28257         return ret_conv;
28258 }
28259
28260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28261         LDKChannelHandshakeLimits this_ptr_conv;
28262         this_ptr_conv.inner = untag_ptr(this_ptr);
28263         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28265         this_ptr_conv.is_owned = false;
28266         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
28267 }
28268
28269 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
28270         LDKChannelHandshakeLimits this_ptr_conv;
28271         this_ptr_conv.inner = untag_ptr(this_ptr);
28272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28274         this_ptr_conv.is_owned = false;
28275         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
28276         return ret_conv;
28277 }
28278
28279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28280         LDKChannelHandshakeLimits this_ptr_conv;
28281         this_ptr_conv.inner = untag_ptr(this_ptr);
28282         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28284         this_ptr_conv.is_owned = false;
28285         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
28286 }
28287
28288 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
28289         LDKChannelHandshakeLimits this_ptr_conv;
28290         this_ptr_conv.inner = untag_ptr(this_ptr);
28291         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28293         this_ptr_conv.is_owned = false;
28294         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
28295         return ret_conv;
28296 }
28297
28298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28299         LDKChannelHandshakeLimits this_ptr_conv;
28300         this_ptr_conv.inner = untag_ptr(this_ptr);
28301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28303         this_ptr_conv.is_owned = false;
28304         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
28305 }
28306
28307 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28308         LDKChannelHandshakeLimits this_ptr_conv;
28309         this_ptr_conv.inner = untag_ptr(this_ptr);
28310         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28312         this_ptr_conv.is_owned = false;
28313         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
28314         return ret_conv;
28315 }
28316
28317 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) {
28318         LDKChannelHandshakeLimits this_ptr_conv;
28319         this_ptr_conv.inner = untag_ptr(this_ptr);
28320         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28322         this_ptr_conv.is_owned = false;
28323         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
28324 }
28325
28326 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) {
28327         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);
28328         int64_t ret_ref = 0;
28329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28330         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28331         return ret_ref;
28332 }
28333
28334 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
28335         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
28336         int64_t ret_ref = 0;
28337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28338         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28339         return ret_ref;
28340 }
28341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28342         LDKChannelHandshakeLimits arg_conv;
28343         arg_conv.inner = untag_ptr(arg);
28344         arg_conv.is_owned = ptr_is_owned(arg);
28345         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28346         arg_conv.is_owned = false;
28347         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
28348         return ret_conv;
28349 }
28350
28351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28352         LDKChannelHandshakeLimits orig_conv;
28353         orig_conv.inner = untag_ptr(orig);
28354         orig_conv.is_owned = ptr_is_owned(orig);
28355         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28356         orig_conv.is_owned = false;
28357         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
28358         int64_t ret_ref = 0;
28359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28360         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28361         return ret_ref;
28362 }
28363
28364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
28365         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
28366         int64_t ret_ref = 0;
28367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28368         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28369         return ret_ref;
28370 }
28371
28372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28373         LDKChannelConfig this_obj_conv;
28374         this_obj_conv.inner = untag_ptr(this_obj);
28375         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28377         ChannelConfig_free(this_obj_conv);
28378 }
28379
28380 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
28381         LDKChannelConfig this_ptr_conv;
28382         this_ptr_conv.inner = untag_ptr(this_ptr);
28383         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28385         this_ptr_conv.is_owned = false;
28386         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
28387         return ret_conv;
28388 }
28389
28390 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) {
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         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
28397 }
28398
28399 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28400         LDKChannelConfig this_ptr_conv;
28401         this_ptr_conv.inner = untag_ptr(this_ptr);
28402         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28404         this_ptr_conv.is_owned = false;
28405         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
28406         return ret_conv;
28407 }
28408
28409 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) {
28410         LDKChannelConfig this_ptr_conv;
28411         this_ptr_conv.inner = untag_ptr(this_ptr);
28412         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28414         this_ptr_conv.is_owned = false;
28415         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
28416 }
28417
28418 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
28419         LDKChannelConfig this_ptr_conv;
28420         this_ptr_conv.inner = untag_ptr(this_ptr);
28421         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28423         this_ptr_conv.is_owned = false;
28424         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
28425         return ret_conv;
28426 }
28427
28428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28429         LDKChannelConfig this_ptr_conv;
28430         this_ptr_conv.inner = untag_ptr(this_ptr);
28431         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28433         this_ptr_conv.is_owned = false;
28434         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
28435 }
28436
28437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28438         LDKChannelConfig this_ptr_conv;
28439         this_ptr_conv.inner = untag_ptr(this_ptr);
28440         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28442         this_ptr_conv.is_owned = false;
28443         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
28444         return ret_conv;
28445 }
28446
28447 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) {
28448         LDKChannelConfig this_ptr_conv;
28449         this_ptr_conv.inner = untag_ptr(this_ptr);
28450         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28452         this_ptr_conv.is_owned = false;
28453         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
28454 }
28455
28456 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) {
28457         LDKChannelConfig this_ptr_conv;
28458         this_ptr_conv.inner = untag_ptr(this_ptr);
28459         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28461         this_ptr_conv.is_owned = false;
28462         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
28463         return ret_conv;
28464 }
28465
28466 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) {
28467         LDKChannelConfig this_ptr_conv;
28468         this_ptr_conv.inner = untag_ptr(this_ptr);
28469         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28471         this_ptr_conv.is_owned = false;
28472         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
28473 }
28474
28475 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) {
28476         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);
28477         int64_t ret_ref = 0;
28478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28479         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28480         return ret_ref;
28481 }
28482
28483 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
28484         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
28485         int64_t ret_ref = 0;
28486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28487         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28488         return ret_ref;
28489 }
28490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28491         LDKChannelConfig arg_conv;
28492         arg_conv.inner = untag_ptr(arg);
28493         arg_conv.is_owned = ptr_is_owned(arg);
28494         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28495         arg_conv.is_owned = false;
28496         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
28497         return ret_conv;
28498 }
28499
28500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28501         LDKChannelConfig orig_conv;
28502         orig_conv.inner = untag_ptr(orig);
28503         orig_conv.is_owned = ptr_is_owned(orig);
28504         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28505         orig_conv.is_owned = false;
28506         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
28507         int64_t ret_ref = 0;
28508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28509         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28510         return ret_ref;
28511 }
28512
28513 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28514         LDKChannelConfig a_conv;
28515         a_conv.inner = untag_ptr(a);
28516         a_conv.is_owned = ptr_is_owned(a);
28517         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28518         a_conv.is_owned = false;
28519         LDKChannelConfig b_conv;
28520         b_conv.inner = untag_ptr(b);
28521         b_conv.is_owned = ptr_is_owned(b);
28522         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28523         b_conv.is_owned = false;
28524         jboolean ret_conv = ChannelConfig_eq(&a_conv, &b_conv);
28525         return ret_conv;
28526 }
28527
28528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
28529         LDKChannelConfig ret_var = ChannelConfig_default();
28530         int64_t ret_ref = 0;
28531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28532         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28533         return ret_ref;
28534 }
28535
28536 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
28537         LDKChannelConfig obj_conv;
28538         obj_conv.inner = untag_ptr(obj);
28539         obj_conv.is_owned = ptr_is_owned(obj);
28540         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28541         obj_conv.is_owned = false;
28542         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
28543         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28544         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28545         CVec_u8Z_free(ret_var);
28546         return ret_arr;
28547 }
28548
28549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28550         LDKu8slice ser_ref;
28551         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28552         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28553         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
28554         *ret_conv = ChannelConfig_read(ser_ref);
28555         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28556         return tag_ptr(ret_conv, true);
28557 }
28558
28559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28560         LDKUserConfig this_obj_conv;
28561         this_obj_conv.inner = untag_ptr(this_obj);
28562         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28564         UserConfig_free(this_obj_conv);
28565 }
28566
28567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
28568         LDKUserConfig this_ptr_conv;
28569         this_ptr_conv.inner = untag_ptr(this_ptr);
28570         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28572         this_ptr_conv.is_owned = false;
28573         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
28574         int64_t ret_ref = 0;
28575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28576         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28577         return ret_ref;
28578 }
28579
28580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28581         LDKUserConfig this_ptr_conv;
28582         this_ptr_conv.inner = untag_ptr(this_ptr);
28583         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28585         this_ptr_conv.is_owned = false;
28586         LDKChannelHandshakeConfig val_conv;
28587         val_conv.inner = untag_ptr(val);
28588         val_conv.is_owned = ptr_is_owned(val);
28589         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28590         val_conv = ChannelHandshakeConfig_clone(&val_conv);
28591         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
28592 }
28593
28594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
28595         LDKUserConfig this_ptr_conv;
28596         this_ptr_conv.inner = untag_ptr(this_ptr);
28597         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28599         this_ptr_conv.is_owned = false;
28600         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
28601         int64_t ret_ref = 0;
28602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28603         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28604         return ret_ref;
28605 }
28606
28607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28608         LDKUserConfig this_ptr_conv;
28609         this_ptr_conv.inner = untag_ptr(this_ptr);
28610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28612         this_ptr_conv.is_owned = false;
28613         LDKChannelHandshakeLimits val_conv;
28614         val_conv.inner = untag_ptr(val);
28615         val_conv.is_owned = ptr_is_owned(val);
28616         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28617         val_conv = ChannelHandshakeLimits_clone(&val_conv);
28618         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
28619 }
28620
28621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
28622         LDKUserConfig this_ptr_conv;
28623         this_ptr_conv.inner = untag_ptr(this_ptr);
28624         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28626         this_ptr_conv.is_owned = false;
28627         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
28628         int64_t ret_ref = 0;
28629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28630         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28631         return ret_ref;
28632 }
28633
28634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28635         LDKUserConfig this_ptr_conv;
28636         this_ptr_conv.inner = untag_ptr(this_ptr);
28637         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28639         this_ptr_conv.is_owned = false;
28640         LDKChannelConfig val_conv;
28641         val_conv.inner = untag_ptr(val);
28642         val_conv.is_owned = ptr_is_owned(val);
28643         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28644         val_conv = ChannelConfig_clone(&val_conv);
28645         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
28646 }
28647
28648 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28649         LDKUserConfig this_ptr_conv;
28650         this_ptr_conv.inner = untag_ptr(this_ptr);
28651         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28653         this_ptr_conv.is_owned = false;
28654         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
28655         return ret_conv;
28656 }
28657
28658 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) {
28659         LDKUserConfig this_ptr_conv;
28660         this_ptr_conv.inner = untag_ptr(this_ptr);
28661         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28663         this_ptr_conv.is_owned = false;
28664         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
28665 }
28666
28667 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28668         LDKUserConfig this_ptr_conv;
28669         this_ptr_conv.inner = untag_ptr(this_ptr);
28670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28672         this_ptr_conv.is_owned = false;
28673         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
28674         return ret_conv;
28675 }
28676
28677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28678         LDKUserConfig this_ptr_conv;
28679         this_ptr_conv.inner = untag_ptr(this_ptr);
28680         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28682         this_ptr_conv.is_owned = false;
28683         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
28684 }
28685
28686 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28687         LDKUserConfig this_ptr_conv;
28688         this_ptr_conv.inner = untag_ptr(this_ptr);
28689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28691         this_ptr_conv.is_owned = false;
28692         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
28693         return ret_conv;
28694 }
28695
28696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28697         LDKUserConfig this_ptr_conv;
28698         this_ptr_conv.inner = untag_ptr(this_ptr);
28699         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28701         this_ptr_conv.is_owned = false;
28702         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
28703 }
28704
28705 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1intercept_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28706         LDKUserConfig this_ptr_conv;
28707         this_ptr_conv.inner = untag_ptr(this_ptr);
28708         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28710         this_ptr_conv.is_owned = false;
28711         jboolean ret_conv = UserConfig_get_accept_intercept_htlcs(&this_ptr_conv);
28712         return ret_conv;
28713 }
28714
28715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1intercept_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28716         LDKUserConfig this_ptr_conv;
28717         this_ptr_conv.inner = untag_ptr(this_ptr);
28718         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28720         this_ptr_conv.is_owned = false;
28721         UserConfig_set_accept_intercept_htlcs(&this_ptr_conv, val);
28722 }
28723
28724 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) {
28725         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
28726         channel_handshake_config_arg_conv.inner = untag_ptr(channel_handshake_config_arg);
28727         channel_handshake_config_arg_conv.is_owned = ptr_is_owned(channel_handshake_config_arg);
28728         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
28729         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
28730         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
28731         channel_handshake_limits_arg_conv.inner = untag_ptr(channel_handshake_limits_arg);
28732         channel_handshake_limits_arg_conv.is_owned = ptr_is_owned(channel_handshake_limits_arg);
28733         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
28734         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
28735         LDKChannelConfig channel_config_arg_conv;
28736         channel_config_arg_conv.inner = untag_ptr(channel_config_arg);
28737         channel_config_arg_conv.is_owned = ptr_is_owned(channel_config_arg);
28738         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
28739         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
28740         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);
28741         int64_t ret_ref = 0;
28742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28743         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28744         return ret_ref;
28745 }
28746
28747 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
28748         LDKUserConfig ret_var = UserConfig_clone(arg);
28749         int64_t ret_ref = 0;
28750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28751         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28752         return ret_ref;
28753 }
28754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28755         LDKUserConfig arg_conv;
28756         arg_conv.inner = untag_ptr(arg);
28757         arg_conv.is_owned = ptr_is_owned(arg);
28758         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28759         arg_conv.is_owned = false;
28760         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
28761         return ret_conv;
28762 }
28763
28764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28765         LDKUserConfig orig_conv;
28766         orig_conv.inner = untag_ptr(orig);
28767         orig_conv.is_owned = ptr_is_owned(orig);
28768         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28769         orig_conv.is_owned = false;
28770         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
28771         int64_t ret_ref = 0;
28772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28773         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28774         return ret_ref;
28775 }
28776
28777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
28778         LDKUserConfig ret_var = UserConfig_default();
28779         int64_t ret_ref = 0;
28780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28781         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28782         return ret_ref;
28783 }
28784
28785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28786         LDKBestBlock this_obj_conv;
28787         this_obj_conv.inner = untag_ptr(this_obj);
28788         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28790         BestBlock_free(this_obj_conv);
28791 }
28792
28793 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
28794         LDKBestBlock ret_var = BestBlock_clone(arg);
28795         int64_t ret_ref = 0;
28796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28798         return ret_ref;
28799 }
28800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28801         LDKBestBlock arg_conv;
28802         arg_conv.inner = untag_ptr(arg);
28803         arg_conv.is_owned = ptr_is_owned(arg);
28804         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28805         arg_conv.is_owned = false;
28806         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
28807         return ret_conv;
28808 }
28809
28810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28811         LDKBestBlock orig_conv;
28812         orig_conv.inner = untag_ptr(orig);
28813         orig_conv.is_owned = ptr_is_owned(orig);
28814         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28815         orig_conv.is_owned = false;
28816         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
28817         int64_t ret_ref = 0;
28818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28819         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28820         return ret_ref;
28821 }
28822
28823 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BestBlock_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28824         LDKBestBlock a_conv;
28825         a_conv.inner = untag_ptr(a);
28826         a_conv.is_owned = ptr_is_owned(a);
28827         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28828         a_conv.is_owned = false;
28829         LDKBestBlock b_conv;
28830         b_conv.inner = untag_ptr(b);
28831         b_conv.is_owned = ptr_is_owned(b);
28832         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28833         b_conv.is_owned = false;
28834         jboolean ret_conv = BestBlock_eq(&a_conv, &b_conv);
28835         return ret_conv;
28836 }
28837
28838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1network(JNIEnv *env, jclass clz, jclass network) {
28839         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
28840         LDKBestBlock ret_var = BestBlock_from_network(network_conv);
28841         int64_t ret_ref = 0;
28842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28843         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28844         return ret_ref;
28845 }
28846
28847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
28848         LDKThirtyTwoBytes block_hash_ref;
28849         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
28850         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
28851         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
28852         int64_t ret_ref = 0;
28853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28854         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28855         return ret_ref;
28856 }
28857
28858 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
28859         LDKBestBlock this_arg_conv;
28860         this_arg_conv.inner = untag_ptr(this_arg);
28861         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28863         this_arg_conv.is_owned = false;
28864         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28865         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
28866         return ret_arr;
28867 }
28868
28869 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
28870         LDKBestBlock this_arg_conv;
28871         this_arg_conv.inner = untag_ptr(this_arg);
28872         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28874         this_arg_conv.is_owned = false;
28875         int32_t ret_conv = BestBlock_height(&this_arg_conv);
28876         return ret_conv;
28877 }
28878
28879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28880         if (!ptr_is_owned(this_ptr)) return;
28881         void* this_ptr_ptr = untag_ptr(this_ptr);
28882         CHECK_ACCESS(this_ptr_ptr);
28883         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
28884         FREE(untag_ptr(this_ptr));
28885         Listen_free(this_ptr_conv);
28886 }
28887
28888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28889         if (!ptr_is_owned(this_ptr)) return;
28890         void* this_ptr_ptr = untag_ptr(this_ptr);
28891         CHECK_ACCESS(this_ptr_ptr);
28892         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
28893         FREE(untag_ptr(this_ptr));
28894         Confirm_free(this_ptr_conv);
28895 }
28896
28897 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28898         LDKChannelMonitorUpdateStatus* orig_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(orig);
28899         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_clone(orig_conv));
28900         return ret_conv;
28901 }
28902
28903 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1completed(JNIEnv *env, jclass clz) {
28904         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_completed());
28905         return ret_conv;
28906 }
28907
28908 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1in_1progress(JNIEnv *env, jclass clz) {
28909         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_in_progress());
28910         return ret_conv;
28911 }
28912
28913 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1permanent_1failure(JNIEnv *env, jclass clz) {
28914         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_permanent_failure());
28915         return ret_conv;
28916 }
28917
28918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28919         LDKChannelMonitorUpdateStatus* a_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(a);
28920         LDKChannelMonitorUpdateStatus* b_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(b);
28921         jboolean ret_conv = ChannelMonitorUpdateStatus_eq(a_conv, b_conv);
28922         return ret_conv;
28923 }
28924
28925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28926         if (!ptr_is_owned(this_ptr)) return;
28927         void* this_ptr_ptr = untag_ptr(this_ptr);
28928         CHECK_ACCESS(this_ptr_ptr);
28929         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
28930         FREE(untag_ptr(this_ptr));
28931         Watch_free(this_ptr_conv);
28932 }
28933
28934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28935         if (!ptr_is_owned(this_ptr)) return;
28936         void* this_ptr_ptr = untag_ptr(this_ptr);
28937         CHECK_ACCESS(this_ptr_ptr);
28938         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
28939         FREE(untag_ptr(this_ptr));
28940         Filter_free(this_ptr_conv);
28941 }
28942
28943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28944         LDKWatchedOutput this_obj_conv;
28945         this_obj_conv.inner = untag_ptr(this_obj);
28946         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28948         WatchedOutput_free(this_obj_conv);
28949 }
28950
28951 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
28952         LDKWatchedOutput this_ptr_conv;
28953         this_ptr_conv.inner = untag_ptr(this_ptr);
28954         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28956         this_ptr_conv.is_owned = false;
28957         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28958         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
28959         return ret_arr;
28960 }
28961
28962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28963         LDKWatchedOutput this_ptr_conv;
28964         this_ptr_conv.inner = untag_ptr(this_ptr);
28965         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28967         this_ptr_conv.is_owned = false;
28968         LDKThirtyTwoBytes val_ref;
28969         CHECK((*env)->GetArrayLength(env, val) == 32);
28970         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28971         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
28972 }
28973
28974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28975         LDKWatchedOutput this_ptr_conv;
28976         this_ptr_conv.inner = untag_ptr(this_ptr);
28977         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28979         this_ptr_conv.is_owned = false;
28980         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
28981         int64_t ret_ref = 0;
28982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28983         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28984         return ret_ref;
28985 }
28986
28987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28988         LDKWatchedOutput this_ptr_conv;
28989         this_ptr_conv.inner = untag_ptr(this_ptr);
28990         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28992         this_ptr_conv.is_owned = false;
28993         LDKOutPoint val_conv;
28994         val_conv.inner = untag_ptr(val);
28995         val_conv.is_owned = ptr_is_owned(val);
28996         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28997         val_conv = OutPoint_clone(&val_conv);
28998         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
28999 }
29000
29001 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
29002         LDKWatchedOutput this_ptr_conv;
29003         this_ptr_conv.inner = untag_ptr(this_ptr);
29004         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29006         this_ptr_conv.is_owned = false;
29007         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
29008         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29009         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29010         return ret_arr;
29011 }
29012
29013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29014         LDKWatchedOutput this_ptr_conv;
29015         this_ptr_conv.inner = untag_ptr(this_ptr);
29016         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29018         this_ptr_conv.is_owned = false;
29019         LDKCVec_u8Z val_ref;
29020         val_ref.datalen = (*env)->GetArrayLength(env, val);
29021         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
29022         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
29023         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
29024 }
29025
29026 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) {
29027         LDKThirtyTwoBytes block_hash_arg_ref;
29028         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
29029         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
29030         LDKOutPoint outpoint_arg_conv;
29031         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
29032         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
29033         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
29034         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
29035         LDKCVec_u8Z script_pubkey_arg_ref;
29036         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
29037         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
29038         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
29039         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
29040         int64_t ret_ref = 0;
29041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29042         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29043         return ret_ref;
29044 }
29045
29046 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
29047         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
29048         int64_t ret_ref = 0;
29049         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29050         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29051         return ret_ref;
29052 }
29053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29054         LDKWatchedOutput arg_conv;
29055         arg_conv.inner = untag_ptr(arg);
29056         arg_conv.is_owned = ptr_is_owned(arg);
29057         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29058         arg_conv.is_owned = false;
29059         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
29060         return ret_conv;
29061 }
29062
29063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29064         LDKWatchedOutput orig_conv;
29065         orig_conv.inner = untag_ptr(orig);
29066         orig_conv.is_owned = ptr_is_owned(orig);
29067         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29068         orig_conv.is_owned = false;
29069         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
29070         int64_t ret_ref = 0;
29071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29072         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29073         return ret_ref;
29074 }
29075
29076 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29077         LDKWatchedOutput a_conv;
29078         a_conv.inner = untag_ptr(a);
29079         a_conv.is_owned = ptr_is_owned(a);
29080         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29081         a_conv.is_owned = false;
29082         LDKWatchedOutput b_conv;
29083         b_conv.inner = untag_ptr(b);
29084         b_conv.is_owned = ptr_is_owned(b);
29085         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29086         b_conv.is_owned = false;
29087         jboolean ret_conv = WatchedOutput_eq(&a_conv, &b_conv);
29088         return ret_conv;
29089 }
29090
29091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
29092         LDKWatchedOutput o_conv;
29093         o_conv.inner = untag_ptr(o);
29094         o_conv.is_owned = ptr_is_owned(o);
29095         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29096         o_conv.is_owned = false;
29097         int64_t ret_conv = WatchedOutput_hash(&o_conv);
29098         return ret_conv;
29099 }
29100
29101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29102         if (!ptr_is_owned(this_ptr)) return;
29103         void* this_ptr_ptr = untag_ptr(this_ptr);
29104         CHECK_ACCESS(this_ptr_ptr);
29105         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
29106         FREE(untag_ptr(this_ptr));
29107         BroadcasterInterface_free(this_ptr_conv);
29108 }
29109
29110 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29111         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)untag_ptr(orig);
29112         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
29113         return ret_conv;
29114 }
29115
29116 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
29117         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
29118         return ret_conv;
29119 }
29120
29121 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
29122         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
29123         return ret_conv;
29124 }
29125
29126 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
29127         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
29128         return ret_conv;
29129 }
29130
29131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1hash(JNIEnv *env, jclass clz, int64_t o) {
29132         LDKConfirmationTarget* o_conv = (LDKConfirmationTarget*)untag_ptr(o);
29133         int64_t ret_conv = ConfirmationTarget_hash(o_conv);
29134         return ret_conv;
29135 }
29136
29137 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29138         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)untag_ptr(a);
29139         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)untag_ptr(b);
29140         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
29141         return ret_conv;
29142 }
29143
29144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29145         if (!ptr_is_owned(this_ptr)) return;
29146         void* this_ptr_ptr = untag_ptr(this_ptr);
29147         CHECK_ACCESS(this_ptr_ptr);
29148         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
29149         FREE(untag_ptr(this_ptr));
29150         FeeEstimator_free(this_ptr_conv);
29151 }
29152
29153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29154         LDKMonitorUpdateId this_obj_conv;
29155         this_obj_conv.inner = untag_ptr(this_obj);
29156         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29158         MonitorUpdateId_free(this_obj_conv);
29159 }
29160
29161 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
29162         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
29163         int64_t ret_ref = 0;
29164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29165         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29166         return ret_ref;
29167 }
29168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29169         LDKMonitorUpdateId arg_conv;
29170         arg_conv.inner = untag_ptr(arg);
29171         arg_conv.is_owned = ptr_is_owned(arg);
29172         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29173         arg_conv.is_owned = false;
29174         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
29175         return ret_conv;
29176 }
29177
29178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29179         LDKMonitorUpdateId orig_conv;
29180         orig_conv.inner = untag_ptr(orig);
29181         orig_conv.is_owned = ptr_is_owned(orig);
29182         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29183         orig_conv.is_owned = false;
29184         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
29185         int64_t ret_ref = 0;
29186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29187         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29188         return ret_ref;
29189 }
29190
29191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
29192         LDKMonitorUpdateId o_conv;
29193         o_conv.inner = untag_ptr(o);
29194         o_conv.is_owned = ptr_is_owned(o);
29195         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29196         o_conv.is_owned = false;
29197         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
29198         return ret_conv;
29199 }
29200
29201 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29202         LDKMonitorUpdateId a_conv;
29203         a_conv.inner = untag_ptr(a);
29204         a_conv.is_owned = ptr_is_owned(a);
29205         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29206         a_conv.is_owned = false;
29207         LDKMonitorUpdateId b_conv;
29208         b_conv.inner = untag_ptr(b);
29209         b_conv.is_owned = ptr_is_owned(b);
29210         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29211         b_conv.is_owned = false;
29212         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
29213         return ret_conv;
29214 }
29215
29216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29217         if (!ptr_is_owned(this_ptr)) return;
29218         void* this_ptr_ptr = untag_ptr(this_ptr);
29219         CHECK_ACCESS(this_ptr_ptr);
29220         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
29221         FREE(untag_ptr(this_ptr));
29222         Persist_free(this_ptr_conv);
29223 }
29224
29225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29226         LDKLockedChannelMonitor this_obj_conv;
29227         this_obj_conv.inner = untag_ptr(this_obj);
29228         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29230         LockedChannelMonitor_free(this_obj_conv);
29231 }
29232
29233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29234         LDKChainMonitor this_obj_conv;
29235         this_obj_conv.inner = untag_ptr(this_obj);
29236         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29238         ChainMonitor_free(this_obj_conv);
29239 }
29240
29241 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) {
29242         void* chain_source_ptr = untag_ptr(chain_source);
29243         CHECK_ACCESS(chain_source_ptr);
29244         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
29245         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
29246         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
29247                 // Manually implement clone for Java trait instances
29248                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
29249                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29250                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
29251                 }
29252         }
29253         void* broadcaster_ptr = untag_ptr(broadcaster);
29254         CHECK_ACCESS(broadcaster_ptr);
29255         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29256         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29257                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29258                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29259         }
29260         void* logger_ptr = untag_ptr(logger);
29261         CHECK_ACCESS(logger_ptr);
29262         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29263         if (logger_conv.free == LDKLogger_JCalls_free) {
29264                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29265                 LDKLogger_JCalls_cloned(&logger_conv);
29266         }
29267         void* feeest_ptr = untag_ptr(feeest);
29268         CHECK_ACCESS(feeest_ptr);
29269         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
29270         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
29271                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29272                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
29273         }
29274         void* persister_ptr = untag_ptr(persister);
29275         CHECK_ACCESS(persister_ptr);
29276         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
29277         if (persister_conv.free == LDKPersist_JCalls_free) {
29278                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29279                 LDKPersist_JCalls_cloned(&persister_conv);
29280         }
29281         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
29282         int64_t ret_ref = 0;
29283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29284         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29285         return ret_ref;
29286 }
29287
29288 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) {
29289         LDKChainMonitor this_arg_conv;
29290         this_arg_conv.inner = untag_ptr(this_arg);
29291         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29293         this_arg_conv.is_owned = false;
29294         LDKCVec_ChannelDetailsZ ignored_channels_constr;
29295         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
29296         if (ignored_channels_constr.datalen > 0)
29297                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29298         else
29299                 ignored_channels_constr.data = NULL;
29300         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
29301         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
29302                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
29303                 LDKChannelDetails ignored_channels_conv_16_conv;
29304                 ignored_channels_conv_16_conv.inner = untag_ptr(ignored_channels_conv_16);
29305                 ignored_channels_conv_16_conv.is_owned = ptr_is_owned(ignored_channels_conv_16);
29306                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
29307                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
29308                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
29309         }
29310         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
29311         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
29312         int64_tArray ret_arr = NULL;
29313         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29314         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29315         for (size_t j = 0; j < ret_var.datalen; j++) {
29316                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29317                 *ret_conv_9_copy = ret_var.data[j];
29318                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
29319                 ret_arr_ptr[j] = ret_conv_9_ref;
29320         }
29321         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29322         FREE(ret_var.data);
29323         return ret_arr;
29324 }
29325
29326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
29327         LDKChainMonitor this_arg_conv;
29328         this_arg_conv.inner = untag_ptr(this_arg);
29329         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29331         this_arg_conv.is_owned = false;
29332         LDKOutPoint funding_txo_conv;
29333         funding_txo_conv.inner = untag_ptr(funding_txo);
29334         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29335         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29336         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29337         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
29338         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
29339         return tag_ptr(ret_conv, true);
29340 }
29341
29342 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
29343         LDKChainMonitor this_arg_conv;
29344         this_arg_conv.inner = untag_ptr(this_arg);
29345         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29347         this_arg_conv.is_owned = false;
29348         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
29349         int64_tArray ret_arr = NULL;
29350         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29351         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29352         for (size_t k = 0; k < ret_var.datalen; k++) {
29353                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
29354                 int64_t ret_conv_10_ref = 0;
29355                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
29356                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
29357                 ret_arr_ptr[k] = ret_conv_10_ref;
29358         }
29359         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29360         FREE(ret_var.data);
29361         return ret_arr;
29362 }
29363
29364 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1pending_1monitor_1updates(JNIEnv *env, jclass clz, int64_t this_arg) {
29365         LDKChainMonitor this_arg_conv;
29366         this_arg_conv.inner = untag_ptr(this_arg);
29367         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29369         this_arg_conv.is_owned = false;
29370         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret_var = ChainMonitor_list_pending_monitor_updates(&this_arg_conv);
29371         int64_tArray ret_arr = NULL;
29372         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29373         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29374         for (size_t p = 0; p < ret_var.datalen; p++) {
29375                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv_41_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
29376                 *ret_conv_41_conv = ret_var.data[p];
29377                 ret_arr_ptr[p] = tag_ptr(ret_conv_41_conv, true);
29378         }
29379         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29380         FREE(ret_var.data);
29381         return ret_arr;
29382 }
29383
29384 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) {
29385         LDKChainMonitor this_arg_conv;
29386         this_arg_conv.inner = untag_ptr(this_arg);
29387         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29389         this_arg_conv.is_owned = false;
29390         LDKOutPoint funding_txo_conv;
29391         funding_txo_conv.inner = untag_ptr(funding_txo);
29392         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29393         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29394         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29395         LDKMonitorUpdateId completed_update_id_conv;
29396         completed_update_id_conv.inner = untag_ptr(completed_update_id);
29397         completed_update_id_conv.is_owned = ptr_is_owned(completed_update_id);
29398         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
29399         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
29400         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29401         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
29402         return tag_ptr(ret_conv, true);
29403 }
29404
29405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
29406         LDKChainMonitor this_arg_conv;
29407         this_arg_conv.inner = untag_ptr(this_arg);
29408         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29410         this_arg_conv.is_owned = false;
29411         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
29412         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
29413         return tag_ptr(ret_ret, true);
29414 }
29415
29416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
29417         LDKChainMonitor this_arg_conv;
29418         this_arg_conv.inner = untag_ptr(this_arg);
29419         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29421         this_arg_conv.is_owned = false;
29422         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
29423         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
29424         return tag_ptr(ret_ret, true);
29425 }
29426
29427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
29428         LDKChainMonitor this_arg_conv;
29429         this_arg_conv.inner = untag_ptr(this_arg);
29430         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29432         this_arg_conv.is_owned = false;
29433         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
29434         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
29435         return tag_ptr(ret_ret, true);
29436 }
29437
29438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29439         LDKChainMonitor this_arg_conv;
29440         this_arg_conv.inner = untag_ptr(this_arg);
29441         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29443         this_arg_conv.is_owned = false;
29444         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
29445         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
29446         return tag_ptr(ret_ret, true);
29447 }
29448
29449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29450         LDKChannelMonitorUpdate this_obj_conv;
29451         this_obj_conv.inner = untag_ptr(this_obj);
29452         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29454         ChannelMonitorUpdate_free(this_obj_conv);
29455 }
29456
29457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29458         LDKChannelMonitorUpdate this_ptr_conv;
29459         this_ptr_conv.inner = untag_ptr(this_ptr);
29460         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29462         this_ptr_conv.is_owned = false;
29463         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
29464         return ret_conv;
29465 }
29466
29467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29468         LDKChannelMonitorUpdate this_ptr_conv;
29469         this_ptr_conv.inner = untag_ptr(this_ptr);
29470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29472         this_ptr_conv.is_owned = false;
29473         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
29474 }
29475
29476 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
29477         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
29478         int64_t ret_ref = 0;
29479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29480         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29481         return ret_ref;
29482 }
29483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29484         LDKChannelMonitorUpdate arg_conv;
29485         arg_conv.inner = untag_ptr(arg);
29486         arg_conv.is_owned = ptr_is_owned(arg);
29487         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29488         arg_conv.is_owned = false;
29489         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
29490         return ret_conv;
29491 }
29492
29493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29494         LDKChannelMonitorUpdate orig_conv;
29495         orig_conv.inner = untag_ptr(orig);
29496         orig_conv.is_owned = ptr_is_owned(orig);
29497         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29498         orig_conv.is_owned = false;
29499         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
29500         int64_t ret_ref = 0;
29501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29502         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29503         return ret_ref;
29504 }
29505
29506 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
29507         LDKChannelMonitorUpdate obj_conv;
29508         obj_conv.inner = untag_ptr(obj);
29509         obj_conv.is_owned = ptr_is_owned(obj);
29510         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29511         obj_conv.is_owned = false;
29512         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
29513         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29514         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29515         CVec_u8Z_free(ret_var);
29516         return ret_arr;
29517 }
29518
29519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29520         LDKu8slice ser_ref;
29521         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29522         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29523         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
29524         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
29525         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29526         return tag_ptr(ret_conv, true);
29527 }
29528
29529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29530         if (!ptr_is_owned(this_ptr)) return;
29531         void* this_ptr_ptr = untag_ptr(this_ptr);
29532         CHECK_ACCESS(this_ptr_ptr);
29533         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
29534         FREE(untag_ptr(this_ptr));
29535         MonitorEvent_free(this_ptr_conv);
29536 }
29537
29538 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
29539         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29540         *ret_copy = MonitorEvent_clone(arg);
29541         int64_t ret_ref = tag_ptr(ret_copy, true);
29542         return ret_ref;
29543 }
29544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29545         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)untag_ptr(arg);
29546         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
29547         return ret_conv;
29548 }
29549
29550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29551         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)untag_ptr(orig);
29552         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29553         *ret_copy = MonitorEvent_clone(orig_conv);
29554         int64_t ret_ref = tag_ptr(ret_copy, true);
29555         return ret_ref;
29556 }
29557
29558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
29559         LDKHTLCUpdate a_conv;
29560         a_conv.inner = untag_ptr(a);
29561         a_conv.is_owned = ptr_is_owned(a);
29562         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29563         a_conv = HTLCUpdate_clone(&a_conv);
29564         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29565         *ret_copy = MonitorEvent_htlcevent(a_conv);
29566         int64_t ret_ref = tag_ptr(ret_copy, true);
29567         return ret_ref;
29568 }
29569
29570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
29571         LDKOutPoint a_conv;
29572         a_conv.inner = untag_ptr(a);
29573         a_conv.is_owned = ptr_is_owned(a);
29574         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29575         a_conv = OutPoint_clone(&a_conv);
29576         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29577         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
29578         int64_t ret_ref = tag_ptr(ret_copy, true);
29579         return ret_ref;
29580 }
29581
29582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1completed(JNIEnv *env, jclass clz, int64_t funding_txo, int64_t monitor_update_id) {
29583         LDKOutPoint funding_txo_conv;
29584         funding_txo_conv.inner = untag_ptr(funding_txo);
29585         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29586         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29587         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29588         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29589         *ret_copy = MonitorEvent_completed(funding_txo_conv, monitor_update_id);
29590         int64_t ret_ref = tag_ptr(ret_copy, true);
29591         return ret_ref;
29592 }
29593
29594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
29595         LDKOutPoint a_conv;
29596         a_conv.inner = untag_ptr(a);
29597         a_conv.is_owned = ptr_is_owned(a);
29598         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29599         a_conv = OutPoint_clone(&a_conv);
29600         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29601         *ret_copy = MonitorEvent_update_failed(a_conv);
29602         int64_t ret_ref = tag_ptr(ret_copy, true);
29603         return ret_ref;
29604 }
29605
29606 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29607         LDKMonitorEvent* a_conv = (LDKMonitorEvent*)untag_ptr(a);
29608         LDKMonitorEvent* b_conv = (LDKMonitorEvent*)untag_ptr(b);
29609         jboolean ret_conv = MonitorEvent_eq(a_conv, b_conv);
29610         return ret_conv;
29611 }
29612
29613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
29614         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)untag_ptr(obj);
29615         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
29616         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29617         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29618         CVec_u8Z_free(ret_var);
29619         return ret_arr;
29620 }
29621
29622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29623         LDKu8slice ser_ref;
29624         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29625         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29626         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
29627         *ret_conv = MonitorEvent_read(ser_ref);
29628         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29629         return tag_ptr(ret_conv, true);
29630 }
29631
29632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29633         LDKHTLCUpdate this_obj_conv;
29634         this_obj_conv.inner = untag_ptr(this_obj);
29635         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29637         HTLCUpdate_free(this_obj_conv);
29638 }
29639
29640 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
29641         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
29642         int64_t ret_ref = 0;
29643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29644         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29645         return ret_ref;
29646 }
29647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29648         LDKHTLCUpdate arg_conv;
29649         arg_conv.inner = untag_ptr(arg);
29650         arg_conv.is_owned = ptr_is_owned(arg);
29651         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29652         arg_conv.is_owned = false;
29653         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
29654         return ret_conv;
29655 }
29656
29657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29658         LDKHTLCUpdate orig_conv;
29659         orig_conv.inner = untag_ptr(orig);
29660         orig_conv.is_owned = ptr_is_owned(orig);
29661         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29662         orig_conv.is_owned = false;
29663         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
29664         int64_t ret_ref = 0;
29665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29666         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29667         return ret_ref;
29668 }
29669
29670 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29671         LDKHTLCUpdate a_conv;
29672         a_conv.inner = untag_ptr(a);
29673         a_conv.is_owned = ptr_is_owned(a);
29674         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29675         a_conv.is_owned = false;
29676         LDKHTLCUpdate b_conv;
29677         b_conv.inner = untag_ptr(b);
29678         b_conv.is_owned = ptr_is_owned(b);
29679         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29680         b_conv.is_owned = false;
29681         jboolean ret_conv = HTLCUpdate_eq(&a_conv, &b_conv);
29682         return ret_conv;
29683 }
29684
29685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
29686         LDKHTLCUpdate obj_conv;
29687         obj_conv.inner = untag_ptr(obj);
29688         obj_conv.is_owned = ptr_is_owned(obj);
29689         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29690         obj_conv.is_owned = false;
29691         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
29692         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29693         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29694         CVec_u8Z_free(ret_var);
29695         return ret_arr;
29696 }
29697
29698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29699         LDKu8slice ser_ref;
29700         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29701         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29702         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
29703         *ret_conv = HTLCUpdate_read(ser_ref);
29704         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29705         return tag_ptr(ret_conv, true);
29706 }
29707
29708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29709         if (!ptr_is_owned(this_ptr)) return;
29710         void* this_ptr_ptr = untag_ptr(this_ptr);
29711         CHECK_ACCESS(this_ptr_ptr);
29712         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
29713         FREE(untag_ptr(this_ptr));
29714         Balance_free(this_ptr_conv);
29715 }
29716
29717 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
29718         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29719         *ret_copy = Balance_clone(arg);
29720         int64_t ret_ref = tag_ptr(ret_copy, true);
29721         return ret_ref;
29722 }
29723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29724         LDKBalance* arg_conv = (LDKBalance*)untag_ptr(arg);
29725         int64_t ret_conv = Balance_clone_ptr(arg_conv);
29726         return ret_conv;
29727 }
29728
29729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29730         LDKBalance* orig_conv = (LDKBalance*)untag_ptr(orig);
29731         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29732         *ret_copy = Balance_clone(orig_conv);
29733         int64_t ret_ref = tag_ptr(ret_copy, true);
29734         return ret_ref;
29735 }
29736
29737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
29738         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29739         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
29740         int64_t ret_ref = tag_ptr(ret_copy, true);
29741         return ret_ref;
29742 }
29743
29744 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) {
29745         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29746         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
29747         int64_t ret_ref = tag_ptr(ret_copy, true);
29748         return ret_ref;
29749 }
29750
29751 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) {
29752         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29753         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
29754         int64_t ret_ref = tag_ptr(ret_copy, true);
29755         return ret_ref;
29756 }
29757
29758 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) {
29759         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29760         *ret_copy = Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis, claimable_height);
29761         int64_t ret_ref = tag_ptr(ret_copy, true);
29762         return ret_ref;
29763 }
29764
29765 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) {
29766         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29767         *ret_copy = Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis, expiry_height);
29768         int64_t ret_ref = tag_ptr(ret_copy, true);
29769         return ret_ref;
29770 }
29771
29772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1counterparty_1revoked_1output_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
29773         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29774         *ret_copy = Balance_counterparty_revoked_output_claimable(claimable_amount_satoshis);
29775         int64_t ret_ref = tag_ptr(ret_copy, true);
29776         return ret_ref;
29777 }
29778
29779 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29780         LDKBalance* a_conv = (LDKBalance*)untag_ptr(a);
29781         LDKBalance* b_conv = (LDKBalance*)untag_ptr(b);
29782         jboolean ret_conv = Balance_eq(a_conv, b_conv);
29783         return ret_conv;
29784 }
29785
29786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29787         LDKChannelMonitor this_obj_conv;
29788         this_obj_conv.inner = untag_ptr(this_obj);
29789         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29791         ChannelMonitor_free(this_obj_conv);
29792 }
29793
29794 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
29795         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
29796         int64_t ret_ref = 0;
29797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29798         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29799         return ret_ref;
29800 }
29801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29802         LDKChannelMonitor arg_conv;
29803         arg_conv.inner = untag_ptr(arg);
29804         arg_conv.is_owned = ptr_is_owned(arg);
29805         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29806         arg_conv.is_owned = false;
29807         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
29808         return ret_conv;
29809 }
29810
29811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29812         LDKChannelMonitor orig_conv;
29813         orig_conv.inner = untag_ptr(orig);
29814         orig_conv.is_owned = ptr_is_owned(orig);
29815         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29816         orig_conv.is_owned = false;
29817         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
29818         int64_t ret_ref = 0;
29819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29820         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29821         return ret_ref;
29822 }
29823
29824 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
29825         LDKChannelMonitor obj_conv;
29826         obj_conv.inner = untag_ptr(obj);
29827         obj_conv.is_owned = ptr_is_owned(obj);
29828         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29829         obj_conv.is_owned = false;
29830         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
29831         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29832         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29833         CVec_u8Z_free(ret_var);
29834         return ret_arr;
29835 }
29836
29837 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) {
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         LDKChannelMonitorUpdate updates_conv;
29844         updates_conv.inner = untag_ptr(updates);
29845         updates_conv.is_owned = ptr_is_owned(updates);
29846         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
29847         updates_conv.is_owned = false;
29848         void* broadcaster_ptr = untag_ptr(broadcaster);
29849         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
29850         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
29851         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29852         CHECK_ACCESS(fee_estimator_ptr);
29853         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29854         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29855                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29856                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29857         }
29858         void* logger_ptr = untag_ptr(logger);
29859         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
29860         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
29861         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
29862         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
29863         return tag_ptr(ret_conv, true);
29864 }
29865
29866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29867         LDKChannelMonitor this_arg_conv;
29868         this_arg_conv.inner = untag_ptr(this_arg);
29869         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29871         this_arg_conv.is_owned = false;
29872         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
29873         return ret_conv;
29874 }
29875
29876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
29877         LDKChannelMonitor this_arg_conv;
29878         this_arg_conv.inner = untag_ptr(this_arg);
29879         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29881         this_arg_conv.is_owned = false;
29882         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
29883         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
29884         return tag_ptr(ret_conv, true);
29885 }
29886
29887 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
29888         LDKChannelMonitor this_arg_conv;
29889         this_arg_conv.inner = untag_ptr(this_arg);
29890         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29892         this_arg_conv.is_owned = false;
29893         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
29894         int64_tArray ret_arr = NULL;
29895         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29896         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29897         for (size_t o = 0; o < ret_var.datalen; o++) {
29898                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
29899                 *ret_conv_40_conv = ret_var.data[o];
29900                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
29901         }
29902         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29903         FREE(ret_var.data);
29904         return ret_arr;
29905 }
29906
29907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
29908         LDKChannelMonitor this_arg_conv;
29909         this_arg_conv.inner = untag_ptr(this_arg);
29910         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29912         this_arg_conv.is_owned = false;
29913         void* filter_ptr = untag_ptr(filter);
29914         if (ptr_is_owned(filter)) { CHECK_ACCESS(filter_ptr); }
29915         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
29916         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
29917 }
29918
29919 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
29920         LDKChannelMonitor this_arg_conv;
29921         this_arg_conv.inner = untag_ptr(this_arg);
29922         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29924         this_arg_conv.is_owned = false;
29925         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
29926         int64_tArray ret_arr = NULL;
29927         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29928         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29929         for (size_t o = 0; o < ret_var.datalen; o++) {
29930                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29931                 *ret_conv_14_copy = ret_var.data[o];
29932                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
29933                 ret_arr_ptr[o] = ret_conv_14_ref;
29934         }
29935         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29936         FREE(ret_var.data);
29937         return ret_arr;
29938 }
29939
29940 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
29941         LDKChannelMonitor this_arg_conv;
29942         this_arg_conv.inner = untag_ptr(this_arg);
29943         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29945         this_arg_conv.is_owned = false;
29946         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
29947         int64_tArray ret_arr = NULL;
29948         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29949         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29950         for (size_t h = 0; h < ret_var.datalen; h++) {
29951                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
29952                 *ret_conv_7_copy = ret_var.data[h];
29953                 int64_t ret_conv_7_ref = tag_ptr(ret_conv_7_copy, true);
29954                 ret_arr_ptr[h] = ret_conv_7_ref;
29955         }
29956         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29957         FREE(ret_var.data);
29958         return ret_arr;
29959 }
29960
29961 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1counterparty_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29962         LDKChannelMonitor this_arg_conv;
29963         this_arg_conv.inner = untag_ptr(this_arg);
29964         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29966         this_arg_conv.is_owned = false;
29967         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29968         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form);
29969         return ret_arr;
29970 }
29971
29972 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) {
29973         LDKChannelMonitor this_arg_conv;
29974         this_arg_conv.inner = untag_ptr(this_arg);
29975         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29977         this_arg_conv.is_owned = false;
29978         void* logger_ptr = untag_ptr(logger);
29979         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
29980         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
29981         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
29982         jobjectArray ret_arr = NULL;
29983         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
29984         ;
29985         for (size_t i = 0; i < ret_var.datalen; i++) {
29986                 LDKTransaction ret_conv_8_var = ret_var.data[i];
29987                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
29988                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
29989                 Transaction_free(ret_conv_8_var);
29990                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
29991         }
29992         
29993         FREE(ret_var.data);
29994         return ret_arr;
29995 }
29996
29997 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) {
29998         LDKChannelMonitor this_arg_conv;
29999         this_arg_conv.inner = untag_ptr(this_arg);
30000         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30002         this_arg_conv.is_owned = false;
30003         uint8_t header_arr[80];
30004         CHECK((*env)->GetArrayLength(env, header) == 80);
30005         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30006         uint8_t (*header_ref)[80] = &header_arr;
30007         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
30008         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
30009         if (txdata_constr.datalen > 0)
30010                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
30011         else
30012                 txdata_constr.data = NULL;
30013         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
30014         for (size_t c = 0; c < txdata_constr.datalen; c++) {
30015                 int64_t txdata_conv_28 = txdata_vals[c];
30016                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
30017                 CHECK_ACCESS(txdata_conv_28_ptr);
30018                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
30019                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
30020                 txdata_constr.data[c] = txdata_conv_28_conv;
30021         }
30022         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
30023         void* broadcaster_ptr = untag_ptr(broadcaster);
30024         CHECK_ACCESS(broadcaster_ptr);
30025         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30026         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30027                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30028                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30029         }
30030         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30031         CHECK_ACCESS(fee_estimator_ptr);
30032         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30033         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30034                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30035                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30036         }
30037         void* logger_ptr = untag_ptr(logger);
30038         CHECK_ACCESS(logger_ptr);
30039         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30040         if (logger_conv.free == LDKLogger_JCalls_free) {
30041                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30042                 LDKLogger_JCalls_cloned(&logger_conv);
30043         }
30044         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);
30045         int64_tArray ret_arr = NULL;
30046         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30047         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30048         for (size_t n = 0; n < ret_var.datalen; n++) {
30049                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
30050                 *ret_conv_39_conv = ret_var.data[n];
30051                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
30052         }
30053         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30054         FREE(ret_var.data);
30055         return ret_arr;
30056 }
30057
30058 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) {
30059         LDKChannelMonitor this_arg_conv;
30060         this_arg_conv.inner = untag_ptr(this_arg);
30061         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30063         this_arg_conv.is_owned = false;
30064         uint8_t header_arr[80];
30065         CHECK((*env)->GetArrayLength(env, header) == 80);
30066         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30067         uint8_t (*header_ref)[80] = &header_arr;
30068         void* broadcaster_ptr = untag_ptr(broadcaster);
30069         CHECK_ACCESS(broadcaster_ptr);
30070         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30071         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30072                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30073                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30074         }
30075         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30076         CHECK_ACCESS(fee_estimator_ptr);
30077         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30078         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30079                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30080                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30081         }
30082         void* logger_ptr = untag_ptr(logger);
30083         CHECK_ACCESS(logger_ptr);
30084         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30085         if (logger_conv.free == LDKLogger_JCalls_free) {
30086                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30087                 LDKLogger_JCalls_cloned(&logger_conv);
30088         }
30089         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
30090 }
30091
30092 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) {
30093         LDKChannelMonitor this_arg_conv;
30094         this_arg_conv.inner = untag_ptr(this_arg);
30095         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30097         this_arg_conv.is_owned = false;
30098         uint8_t header_arr[80];
30099         CHECK((*env)->GetArrayLength(env, header) == 80);
30100         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30101         uint8_t (*header_ref)[80] = &header_arr;
30102         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
30103         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
30104         if (txdata_constr.datalen > 0)
30105                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
30106         else
30107                 txdata_constr.data = NULL;
30108         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
30109         for (size_t c = 0; c < txdata_constr.datalen; c++) {
30110                 int64_t txdata_conv_28 = txdata_vals[c];
30111                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
30112                 CHECK_ACCESS(txdata_conv_28_ptr);
30113                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
30114                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
30115                 txdata_constr.data[c] = txdata_conv_28_conv;
30116         }
30117         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
30118         void* broadcaster_ptr = untag_ptr(broadcaster);
30119         CHECK_ACCESS(broadcaster_ptr);
30120         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30121         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30122                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30123                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30124         }
30125         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30126         CHECK_ACCESS(fee_estimator_ptr);
30127         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30128         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30129                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30130                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30131         }
30132         void* logger_ptr = untag_ptr(logger);
30133         CHECK_ACCESS(logger_ptr);
30134         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30135         if (logger_conv.free == LDKLogger_JCalls_free) {
30136                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30137                 LDKLogger_JCalls_cloned(&logger_conv);
30138         }
30139         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);
30140         int64_tArray ret_arr = NULL;
30141         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30142         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30143         for (size_t n = 0; n < ret_var.datalen; n++) {
30144                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
30145                 *ret_conv_39_conv = ret_var.data[n];
30146                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
30147         }
30148         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30149         FREE(ret_var.data);
30150         return ret_arr;
30151 }
30152
30153 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) {
30154         LDKChannelMonitor this_arg_conv;
30155         this_arg_conv.inner = untag_ptr(this_arg);
30156         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30158         this_arg_conv.is_owned = false;
30159         uint8_t txid_arr[32];
30160         CHECK((*env)->GetArrayLength(env, txid) == 32);
30161         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
30162         uint8_t (*txid_ref)[32] = &txid_arr;
30163         void* broadcaster_ptr = untag_ptr(broadcaster);
30164         CHECK_ACCESS(broadcaster_ptr);
30165         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30166         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30167                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30168                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30169         }
30170         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30171         CHECK_ACCESS(fee_estimator_ptr);
30172         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30173         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30174                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30175                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30176         }
30177         void* logger_ptr = untag_ptr(logger);
30178         CHECK_ACCESS(logger_ptr);
30179         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30180         if (logger_conv.free == LDKLogger_JCalls_free) {
30181                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30182                 LDKLogger_JCalls_cloned(&logger_conv);
30183         }
30184         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
30185 }
30186
30187 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) {
30188         LDKChannelMonitor this_arg_conv;
30189         this_arg_conv.inner = untag_ptr(this_arg);
30190         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30192         this_arg_conv.is_owned = false;
30193         uint8_t header_arr[80];
30194         CHECK((*env)->GetArrayLength(env, header) == 80);
30195         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30196         uint8_t (*header_ref)[80] = &header_arr;
30197         void* broadcaster_ptr = untag_ptr(broadcaster);
30198         CHECK_ACCESS(broadcaster_ptr);
30199         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30200         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30201                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30202                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30203         }
30204         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30205         CHECK_ACCESS(fee_estimator_ptr);
30206         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30207         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30208                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30209                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30210         }
30211         void* logger_ptr = untag_ptr(logger);
30212         CHECK_ACCESS(logger_ptr);
30213         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30214         if (logger_conv.free == LDKLogger_JCalls_free) {
30215                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30216                 LDKLogger_JCalls_cloned(&logger_conv);
30217         }
30218         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
30219         int64_tArray ret_arr = NULL;
30220         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30221         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30222         for (size_t n = 0; n < ret_var.datalen; n++) {
30223                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
30224                 *ret_conv_39_conv = ret_var.data[n];
30225                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
30226         }
30227         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30228         FREE(ret_var.data);
30229         return ret_arr;
30230 }
30231
30232 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
30233         LDKChannelMonitor this_arg_conv;
30234         this_arg_conv.inner = untag_ptr(this_arg);
30235         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30237         this_arg_conv.is_owned = false;
30238         LDKCVec_C2Tuple_TxidBlockHashZZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
30239         int64_tArray ret_arr = NULL;
30240         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30241         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30242         for (size_t z = 0; z < ret_var.datalen; z++) {
30243                 LDKC2Tuple_TxidBlockHashZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
30244                 *ret_conv_25_conv = ret_var.data[z];
30245                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
30246         }
30247         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30248         FREE(ret_var.data);
30249         return ret_arr;
30250 }
30251
30252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
30253         LDKChannelMonitor this_arg_conv;
30254         this_arg_conv.inner = untag_ptr(this_arg);
30255         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30257         this_arg_conv.is_owned = false;
30258         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
30259         int64_t ret_ref = 0;
30260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30261         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30262         return ret_ref;
30263 }
30264
30265 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
30266         LDKChannelMonitor this_arg_conv;
30267         this_arg_conv.inner = untag_ptr(this_arg);
30268         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30270         this_arg_conv.is_owned = false;
30271         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
30272         int64_tArray ret_arr = NULL;
30273         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30274         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30275         for (size_t j = 0; j < ret_var.datalen; j++) {
30276                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
30277                 *ret_conv_9_copy = ret_var.data[j];
30278                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
30279                 ret_arr_ptr[j] = ret_conv_9_ref;
30280         }
30281         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30282         FREE(ret_var.data);
30283         return ret_arr;
30284 }
30285
30286 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) {
30287         LDKu8slice ser_ref;
30288         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30289         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30290         void* arg_a_ptr = untag_ptr(arg_a);
30291         if (ptr_is_owned(arg_a)) { CHECK_ACCESS(arg_a_ptr); }
30292         LDKEntropySource* arg_a_conv = (LDKEntropySource*)arg_a_ptr;
30293         void* arg_b_ptr = untag_ptr(arg_b);
30294         if (ptr_is_owned(arg_b)) { CHECK_ACCESS(arg_b_ptr); }
30295         LDKSignerProvider* arg_b_conv = (LDKSignerProvider*)arg_b_ptr;
30296         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
30297         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_a_conv, arg_b_conv);
30298         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30299         return tag_ptr(ret_conv, true);
30300 }
30301
30302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30303         LDKOutPoint this_obj_conv;
30304         this_obj_conv.inner = untag_ptr(this_obj);
30305         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30307         OutPoint_free(this_obj_conv);
30308 }
30309
30310 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
30311         LDKOutPoint this_ptr_conv;
30312         this_ptr_conv.inner = untag_ptr(this_ptr);
30313         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30315         this_ptr_conv.is_owned = false;
30316         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30317         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
30318         return ret_arr;
30319 }
30320
30321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30322         LDKOutPoint this_ptr_conv;
30323         this_ptr_conv.inner = untag_ptr(this_ptr);
30324         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30326         this_ptr_conv.is_owned = false;
30327         LDKThirtyTwoBytes val_ref;
30328         CHECK((*env)->GetArrayLength(env, val) == 32);
30329         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30330         OutPoint_set_txid(&this_ptr_conv, val_ref);
30331 }
30332
30333 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
30334         LDKOutPoint this_ptr_conv;
30335         this_ptr_conv.inner = untag_ptr(this_ptr);
30336         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30338         this_ptr_conv.is_owned = false;
30339         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
30340         return ret_conv;
30341 }
30342
30343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30344         LDKOutPoint this_ptr_conv;
30345         this_ptr_conv.inner = untag_ptr(this_ptr);
30346         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30348         this_ptr_conv.is_owned = false;
30349         OutPoint_set_index(&this_ptr_conv, val);
30350 }
30351
30352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
30353         LDKThirtyTwoBytes txid_arg_ref;
30354         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
30355         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
30356         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
30357         int64_t ret_ref = 0;
30358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30359         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30360         return ret_ref;
30361 }
30362
30363 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
30364         LDKOutPoint ret_var = OutPoint_clone(arg);
30365         int64_t ret_ref = 0;
30366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30367         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30368         return ret_ref;
30369 }
30370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30371         LDKOutPoint arg_conv;
30372         arg_conv.inner = untag_ptr(arg);
30373         arg_conv.is_owned = ptr_is_owned(arg);
30374         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30375         arg_conv.is_owned = false;
30376         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
30377         return ret_conv;
30378 }
30379
30380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30381         LDKOutPoint orig_conv;
30382         orig_conv.inner = untag_ptr(orig);
30383         orig_conv.is_owned = ptr_is_owned(orig);
30384         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30385         orig_conv.is_owned = false;
30386         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
30387         int64_t ret_ref = 0;
30388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30389         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30390         return ret_ref;
30391 }
30392
30393 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30394         LDKOutPoint a_conv;
30395         a_conv.inner = untag_ptr(a);
30396         a_conv.is_owned = ptr_is_owned(a);
30397         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30398         a_conv.is_owned = false;
30399         LDKOutPoint b_conv;
30400         b_conv.inner = untag_ptr(b);
30401         b_conv.is_owned = ptr_is_owned(b);
30402         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30403         b_conv.is_owned = false;
30404         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
30405         return ret_conv;
30406 }
30407
30408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
30409         LDKOutPoint o_conv;
30410         o_conv.inner = untag_ptr(o);
30411         o_conv.is_owned = ptr_is_owned(o);
30412         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
30413         o_conv.is_owned = false;
30414         int64_t ret_conv = OutPoint_hash(&o_conv);
30415         return ret_conv;
30416 }
30417
30418 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
30419         LDKOutPoint this_arg_conv;
30420         this_arg_conv.inner = untag_ptr(this_arg);
30421         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30423         this_arg_conv.is_owned = false;
30424         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30425         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
30426         return ret_arr;
30427 }
30428
30429 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
30430         LDKOutPoint obj_conv;
30431         obj_conv.inner = untag_ptr(obj);
30432         obj_conv.is_owned = ptr_is_owned(obj);
30433         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30434         obj_conv.is_owned = false;
30435         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
30436         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30437         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30438         CVec_u8Z_free(ret_var);
30439         return ret_arr;
30440 }
30441
30442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30443         LDKu8slice ser_ref;
30444         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30445         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30446         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
30447         *ret_conv = OutPoint_read(ser_ref);
30448         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30449         return tag_ptr(ret_conv, true);
30450 }
30451
30452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30453         LDKDelayedPaymentOutputDescriptor this_obj_conv;
30454         this_obj_conv.inner = untag_ptr(this_obj);
30455         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30457         DelayedPaymentOutputDescriptor_free(this_obj_conv);
30458 }
30459
30460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30461         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30462         this_ptr_conv.inner = untag_ptr(this_ptr);
30463         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30465         this_ptr_conv.is_owned = false;
30466         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
30467         int64_t ret_ref = 0;
30468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30469         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30470         return ret_ref;
30471 }
30472
30473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30474         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30475         this_ptr_conv.inner = untag_ptr(this_ptr);
30476         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30478         this_ptr_conv.is_owned = false;
30479         LDKOutPoint val_conv;
30480         val_conv.inner = untag_ptr(val);
30481         val_conv.is_owned = ptr_is_owned(val);
30482         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30483         val_conv = OutPoint_clone(&val_conv);
30484         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
30485 }
30486
30487 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30488         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30489         this_ptr_conv.inner = untag_ptr(this_ptr);
30490         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30492         this_ptr_conv.is_owned = false;
30493         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30494         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
30495         return ret_arr;
30496 }
30497
30498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30499         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30500         this_ptr_conv.inner = untag_ptr(this_ptr);
30501         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30503         this_ptr_conv.is_owned = false;
30504         LDKPublicKey val_ref;
30505         CHECK((*env)->GetArrayLength(env, val) == 33);
30506         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30507         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
30508 }
30509
30510 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30511         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30512         this_ptr_conv.inner = untag_ptr(this_ptr);
30513         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30515         this_ptr_conv.is_owned = false;
30516         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
30517         return ret_conv;
30518 }
30519
30520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30521         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30522         this_ptr_conv.inner = untag_ptr(this_ptr);
30523         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30525         this_ptr_conv.is_owned = false;
30526         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
30527 }
30528
30529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
30530         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30531         this_ptr_conv.inner = untag_ptr(this_ptr);
30532         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30534         this_ptr_conv.is_owned = false;
30535         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
30536         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
30537         return tag_ptr(ret_ref, true);
30538 }
30539
30540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30541         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30542         this_ptr_conv.inner = untag_ptr(this_ptr);
30543         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30545         this_ptr_conv.is_owned = false;
30546         void* val_ptr = untag_ptr(val);
30547         CHECK_ACCESS(val_ptr);
30548         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
30549         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
30550         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
30551 }
30552
30553 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30554         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30555         this_ptr_conv.inner = untag_ptr(this_ptr);
30556         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30558         this_ptr_conv.is_owned = false;
30559         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30560         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
30561         return ret_arr;
30562 }
30563
30564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30565         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30566         this_ptr_conv.inner = untag_ptr(this_ptr);
30567         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30569         this_ptr_conv.is_owned = false;
30570         LDKPublicKey val_ref;
30571         CHECK((*env)->GetArrayLength(env, val) == 33);
30572         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30573         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
30574 }
30575
30576 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30577         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30578         this_ptr_conv.inner = untag_ptr(this_ptr);
30579         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30581         this_ptr_conv.is_owned = false;
30582         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30583         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
30584         return ret_arr;
30585 }
30586
30587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30588         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30589         this_ptr_conv.inner = untag_ptr(this_ptr);
30590         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30592         this_ptr_conv.is_owned = false;
30593         LDKThirtyTwoBytes val_ref;
30594         CHECK((*env)->GetArrayLength(env, val) == 32);
30595         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30596         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
30597 }
30598
30599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30600         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30601         this_ptr_conv.inner = untag_ptr(this_ptr);
30602         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30604         this_ptr_conv.is_owned = false;
30605         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
30606         return ret_conv;
30607 }
30608
30609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30610         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30611         this_ptr_conv.inner = untag_ptr(this_ptr);
30612         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30614         this_ptr_conv.is_owned = false;
30615         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
30616 }
30617
30618 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) {
30619         LDKOutPoint outpoint_arg_conv;
30620         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
30621         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
30622         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
30623         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
30624         LDKPublicKey per_commitment_point_arg_ref;
30625         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
30626         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
30627         void* output_arg_ptr = untag_ptr(output_arg);
30628         CHECK_ACCESS(output_arg_ptr);
30629         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
30630         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
30631         LDKPublicKey revocation_pubkey_arg_ref;
30632         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
30633         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
30634         LDKThirtyTwoBytes channel_keys_id_arg_ref;
30635         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
30636         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
30637         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);
30638         int64_t ret_ref = 0;
30639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30640         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30641         return ret_ref;
30642 }
30643
30644 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
30645         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
30646         int64_t ret_ref = 0;
30647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30648         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30649         return ret_ref;
30650 }
30651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30652         LDKDelayedPaymentOutputDescriptor arg_conv;
30653         arg_conv.inner = untag_ptr(arg);
30654         arg_conv.is_owned = ptr_is_owned(arg);
30655         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30656         arg_conv.is_owned = false;
30657         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
30658         return ret_conv;
30659 }
30660
30661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30662         LDKDelayedPaymentOutputDescriptor orig_conv;
30663         orig_conv.inner = untag_ptr(orig);
30664         orig_conv.is_owned = ptr_is_owned(orig);
30665         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30666         orig_conv.is_owned = false;
30667         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
30668         int64_t ret_ref = 0;
30669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30670         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30671         return ret_ref;
30672 }
30673
30674 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30675         LDKDelayedPaymentOutputDescriptor a_conv;
30676         a_conv.inner = untag_ptr(a);
30677         a_conv.is_owned = ptr_is_owned(a);
30678         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30679         a_conv.is_owned = false;
30680         LDKDelayedPaymentOutputDescriptor b_conv;
30681         b_conv.inner = untag_ptr(b);
30682         b_conv.is_owned = ptr_is_owned(b);
30683         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30684         b_conv.is_owned = false;
30685         jboolean ret_conv = DelayedPaymentOutputDescriptor_eq(&a_conv, &b_conv);
30686         return ret_conv;
30687 }
30688
30689 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30690         LDKDelayedPaymentOutputDescriptor obj_conv;
30691         obj_conv.inner = untag_ptr(obj);
30692         obj_conv.is_owned = ptr_is_owned(obj);
30693         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30694         obj_conv.is_owned = false;
30695         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
30696         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30697         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30698         CVec_u8Z_free(ret_var);
30699         return ret_arr;
30700 }
30701
30702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30703         LDKu8slice ser_ref;
30704         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30705         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30706         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
30707         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
30708         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30709         return tag_ptr(ret_conv, true);
30710 }
30711
30712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30713         LDKStaticPaymentOutputDescriptor this_obj_conv;
30714         this_obj_conv.inner = untag_ptr(this_obj);
30715         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30717         StaticPaymentOutputDescriptor_free(this_obj_conv);
30718 }
30719
30720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30721         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30722         this_ptr_conv.inner = untag_ptr(this_ptr);
30723         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30725         this_ptr_conv.is_owned = false;
30726         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
30727         int64_t ret_ref = 0;
30728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30729         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30730         return ret_ref;
30731 }
30732
30733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30734         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30735         this_ptr_conv.inner = untag_ptr(this_ptr);
30736         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30738         this_ptr_conv.is_owned = false;
30739         LDKOutPoint val_conv;
30740         val_conv.inner = untag_ptr(val);
30741         val_conv.is_owned = ptr_is_owned(val);
30742         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30743         val_conv = OutPoint_clone(&val_conv);
30744         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
30745 }
30746
30747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
30748         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30749         this_ptr_conv.inner = untag_ptr(this_ptr);
30750         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30752         this_ptr_conv.is_owned = false;
30753         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
30754         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
30755         return tag_ptr(ret_ref, true);
30756 }
30757
30758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30759         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30760         this_ptr_conv.inner = untag_ptr(this_ptr);
30761         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30763         this_ptr_conv.is_owned = false;
30764         void* val_ptr = untag_ptr(val);
30765         CHECK_ACCESS(val_ptr);
30766         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
30767         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
30768         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
30769 }
30770
30771 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30772         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30773         this_ptr_conv.inner = untag_ptr(this_ptr);
30774         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30776         this_ptr_conv.is_owned = false;
30777         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30778         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
30779         return ret_arr;
30780 }
30781
30782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30783         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30784         this_ptr_conv.inner = untag_ptr(this_ptr);
30785         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30787         this_ptr_conv.is_owned = false;
30788         LDKThirtyTwoBytes val_ref;
30789         CHECK((*env)->GetArrayLength(env, val) == 32);
30790         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30791         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
30792 }
30793
30794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30795         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30796         this_ptr_conv.inner = untag_ptr(this_ptr);
30797         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30799         this_ptr_conv.is_owned = false;
30800         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
30801         return ret_conv;
30802 }
30803
30804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30805         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30806         this_ptr_conv.inner = untag_ptr(this_ptr);
30807         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30809         this_ptr_conv.is_owned = false;
30810         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
30811 }
30812
30813 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) {
30814         LDKOutPoint outpoint_arg_conv;
30815         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
30816         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
30817         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
30818         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
30819         void* output_arg_ptr = untag_ptr(output_arg);
30820         CHECK_ACCESS(output_arg_ptr);
30821         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
30822         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
30823         LDKThirtyTwoBytes channel_keys_id_arg_ref;
30824         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
30825         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
30826         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
30827         int64_t ret_ref = 0;
30828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30829         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30830         return ret_ref;
30831 }
30832
30833 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
30834         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
30835         int64_t ret_ref = 0;
30836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30837         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30838         return ret_ref;
30839 }
30840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30841         LDKStaticPaymentOutputDescriptor arg_conv;
30842         arg_conv.inner = untag_ptr(arg);
30843         arg_conv.is_owned = ptr_is_owned(arg);
30844         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30845         arg_conv.is_owned = false;
30846         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
30847         return ret_conv;
30848 }
30849
30850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30851         LDKStaticPaymentOutputDescriptor orig_conv;
30852         orig_conv.inner = untag_ptr(orig);
30853         orig_conv.is_owned = ptr_is_owned(orig);
30854         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30855         orig_conv.is_owned = false;
30856         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
30857         int64_t ret_ref = 0;
30858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30859         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30860         return ret_ref;
30861 }
30862
30863 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30864         LDKStaticPaymentOutputDescriptor a_conv;
30865         a_conv.inner = untag_ptr(a);
30866         a_conv.is_owned = ptr_is_owned(a);
30867         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30868         a_conv.is_owned = false;
30869         LDKStaticPaymentOutputDescriptor b_conv;
30870         b_conv.inner = untag_ptr(b);
30871         b_conv.is_owned = ptr_is_owned(b);
30872         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30873         b_conv.is_owned = false;
30874         jboolean ret_conv = StaticPaymentOutputDescriptor_eq(&a_conv, &b_conv);
30875         return ret_conv;
30876 }
30877
30878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30879         LDKStaticPaymentOutputDescriptor obj_conv;
30880         obj_conv.inner = untag_ptr(obj);
30881         obj_conv.is_owned = ptr_is_owned(obj);
30882         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30883         obj_conv.is_owned = false;
30884         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
30885         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30886         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30887         CVec_u8Z_free(ret_var);
30888         return ret_arr;
30889 }
30890
30891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30892         LDKu8slice ser_ref;
30893         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30894         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30895         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
30896         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
30897         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30898         return tag_ptr(ret_conv, true);
30899 }
30900
30901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30902         if (!ptr_is_owned(this_ptr)) return;
30903         void* this_ptr_ptr = untag_ptr(this_ptr);
30904         CHECK_ACCESS(this_ptr_ptr);
30905         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
30906         FREE(untag_ptr(this_ptr));
30907         SpendableOutputDescriptor_free(this_ptr_conv);
30908 }
30909
30910 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
30911         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30912         *ret_copy = SpendableOutputDescriptor_clone(arg);
30913         int64_t ret_ref = tag_ptr(ret_copy, true);
30914         return ret_ref;
30915 }
30916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30917         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(arg);
30918         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
30919         return ret_conv;
30920 }
30921
30922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30923         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)untag_ptr(orig);
30924         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30925         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
30926         int64_t ret_ref = tag_ptr(ret_copy, true);
30927         return ret_ref;
30928 }
30929
30930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
30931         LDKOutPoint outpoint_conv;
30932         outpoint_conv.inner = untag_ptr(outpoint);
30933         outpoint_conv.is_owned = ptr_is_owned(outpoint);
30934         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
30935         outpoint_conv = OutPoint_clone(&outpoint_conv);
30936         void* output_ptr = untag_ptr(output);
30937         CHECK_ACCESS(output_ptr);
30938         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
30939         output_conv = TxOut_clone((LDKTxOut*)untag_ptr(output));
30940         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30941         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
30942         int64_t ret_ref = tag_ptr(ret_copy, true);
30943         return ret_ref;
30944 }
30945
30946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
30947         LDKDelayedPaymentOutputDescriptor a_conv;
30948         a_conv.inner = untag_ptr(a);
30949         a_conv.is_owned = ptr_is_owned(a);
30950         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30951         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
30952         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30953         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
30954         int64_t ret_ref = tag_ptr(ret_copy, true);
30955         return ret_ref;
30956 }
30957
30958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
30959         LDKStaticPaymentOutputDescriptor a_conv;
30960         a_conv.inner = untag_ptr(a);
30961         a_conv.is_owned = ptr_is_owned(a);
30962         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30963         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
30964         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30965         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
30966         int64_t ret_ref = tag_ptr(ret_copy, true);
30967         return ret_ref;
30968 }
30969
30970 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30971         LDKSpendableOutputDescriptor* a_conv = (LDKSpendableOutputDescriptor*)untag_ptr(a);
30972         LDKSpendableOutputDescriptor* b_conv = (LDKSpendableOutputDescriptor*)untag_ptr(b);
30973         jboolean ret_conv = SpendableOutputDescriptor_eq(a_conv, b_conv);
30974         return ret_conv;
30975 }
30976
30977 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30978         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)untag_ptr(obj);
30979         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
30980         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30981         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30982         CVec_u8Z_free(ret_var);
30983         return ret_arr;
30984 }
30985
30986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30987         LDKu8slice ser_ref;
30988         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30989         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30990         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
30991         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
30992         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30993         return tag_ptr(ret_conv, true);
30994 }
30995
30996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30997         if (!ptr_is_owned(this_ptr)) return;
30998         void* this_ptr_ptr = untag_ptr(this_ptr);
30999         CHECK_ACCESS(this_ptr_ptr);
31000         LDKChannelSigner this_ptr_conv = *(LDKChannelSigner*)(this_ptr_ptr);
31001         FREE(untag_ptr(this_ptr));
31002         ChannelSigner_free(this_ptr_conv);
31003 }
31004
31005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EcdsaChannelSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31006         if (!ptr_is_owned(this_ptr)) return;
31007         void* this_ptr_ptr = untag_ptr(this_ptr);
31008         CHECK_ACCESS(this_ptr_ptr);
31009         LDKEcdsaChannelSigner this_ptr_conv = *(LDKEcdsaChannelSigner*)(this_ptr_ptr);
31010         FREE(untag_ptr(this_ptr));
31011         EcdsaChannelSigner_free(this_ptr_conv);
31012 }
31013
31014 static inline uint64_t WriteableEcdsaChannelSigner_clone_ptr(LDKWriteableEcdsaChannelSigner *NONNULL_PTR arg) {
31015         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
31016         *ret_ret = WriteableEcdsaChannelSigner_clone(arg);
31017         return tag_ptr(ret_ret, true);
31018 }
31019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31020         void* arg_ptr = untag_ptr(arg);
31021         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
31022         LDKWriteableEcdsaChannelSigner* arg_conv = (LDKWriteableEcdsaChannelSigner*)arg_ptr;
31023         int64_t ret_conv = WriteableEcdsaChannelSigner_clone_ptr(arg_conv);
31024         return ret_conv;
31025 }
31026
31027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31028         void* orig_ptr = untag_ptr(orig);
31029         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
31030         LDKWriteableEcdsaChannelSigner* orig_conv = (LDKWriteableEcdsaChannelSigner*)orig_ptr;
31031         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
31032         *ret_ret = WriteableEcdsaChannelSigner_clone(orig_conv);
31033         return tag_ptr(ret_ret, true);
31034 }
31035
31036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31037         if (!ptr_is_owned(this_ptr)) return;
31038         void* this_ptr_ptr = untag_ptr(this_ptr);
31039         CHECK_ACCESS(this_ptr_ptr);
31040         LDKWriteableEcdsaChannelSigner this_ptr_conv = *(LDKWriteableEcdsaChannelSigner*)(this_ptr_ptr);
31041         FREE(untag_ptr(this_ptr));
31042         WriteableEcdsaChannelSigner_free(this_ptr_conv);
31043 }
31044
31045 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31046         LDKRecipient* orig_conv = (LDKRecipient*)untag_ptr(orig);
31047         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
31048         return ret_conv;
31049 }
31050
31051 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
31052         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
31053         return ret_conv;
31054 }
31055
31056 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
31057         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
31058         return ret_conv;
31059 }
31060
31061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EntropySource_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31062         if (!ptr_is_owned(this_ptr)) return;
31063         void* this_ptr_ptr = untag_ptr(this_ptr);
31064         CHECK_ACCESS(this_ptr_ptr);
31065         LDKEntropySource this_ptr_conv = *(LDKEntropySource*)(this_ptr_ptr);
31066         FREE(untag_ptr(this_ptr));
31067         EntropySource_free(this_ptr_conv);
31068 }
31069
31070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31071         if (!ptr_is_owned(this_ptr)) return;
31072         void* this_ptr_ptr = untag_ptr(this_ptr);
31073         CHECK_ACCESS(this_ptr_ptr);
31074         LDKNodeSigner this_ptr_conv = *(LDKNodeSigner*)(this_ptr_ptr);
31075         FREE(untag_ptr(this_ptr));
31076         NodeSigner_free(this_ptr_conv);
31077 }
31078
31079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignerProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31080         if (!ptr_is_owned(this_ptr)) return;
31081         void* this_ptr_ptr = untag_ptr(this_ptr);
31082         CHECK_ACCESS(this_ptr_ptr);
31083         LDKSignerProvider this_ptr_conv = *(LDKSignerProvider*)(this_ptr_ptr);
31084         FREE(untag_ptr(this_ptr));
31085         SignerProvider_free(this_ptr_conv);
31086 }
31087
31088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31089         LDKInMemorySigner this_obj_conv;
31090         this_obj_conv.inner = untag_ptr(this_obj);
31091         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31093         InMemorySigner_free(this_obj_conv);
31094 }
31095
31096 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31097         LDKInMemorySigner this_ptr_conv;
31098         this_ptr_conv.inner = untag_ptr(this_ptr);
31099         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31101         this_ptr_conv.is_owned = false;
31102         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31103         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
31104         return ret_arr;
31105 }
31106
31107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31108         LDKInMemorySigner this_ptr_conv;
31109         this_ptr_conv.inner = untag_ptr(this_ptr);
31110         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31112         this_ptr_conv.is_owned = false;
31113         LDKSecretKey val_ref;
31114         CHECK((*env)->GetArrayLength(env, val) == 32);
31115         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31116         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
31117 }
31118
31119 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31120         LDKInMemorySigner this_ptr_conv;
31121         this_ptr_conv.inner = untag_ptr(this_ptr);
31122         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31124         this_ptr_conv.is_owned = false;
31125         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31126         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
31127         return ret_arr;
31128 }
31129
31130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31131         LDKInMemorySigner this_ptr_conv;
31132         this_ptr_conv.inner = untag_ptr(this_ptr);
31133         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31135         this_ptr_conv.is_owned = false;
31136         LDKSecretKey val_ref;
31137         CHECK((*env)->GetArrayLength(env, val) == 32);
31138         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31139         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
31140 }
31141
31142 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31143         LDKInMemorySigner this_ptr_conv;
31144         this_ptr_conv.inner = untag_ptr(this_ptr);
31145         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31147         this_ptr_conv.is_owned = false;
31148         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31149         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
31150         return ret_arr;
31151 }
31152
31153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31154         LDKInMemorySigner this_ptr_conv;
31155         this_ptr_conv.inner = untag_ptr(this_ptr);
31156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31158         this_ptr_conv.is_owned = false;
31159         LDKSecretKey val_ref;
31160         CHECK((*env)->GetArrayLength(env, val) == 32);
31161         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31162         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
31163 }
31164
31165 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31166         LDKInMemorySigner this_ptr_conv;
31167         this_ptr_conv.inner = untag_ptr(this_ptr);
31168         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31170         this_ptr_conv.is_owned = false;
31171         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31172         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
31173         return ret_arr;
31174 }
31175
31176 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) {
31177         LDKInMemorySigner this_ptr_conv;
31178         this_ptr_conv.inner = untag_ptr(this_ptr);
31179         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31181         this_ptr_conv.is_owned = false;
31182         LDKSecretKey val_ref;
31183         CHECK((*env)->GetArrayLength(env, val) == 32);
31184         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31185         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
31186 }
31187
31188 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31189         LDKInMemorySigner this_ptr_conv;
31190         this_ptr_conv.inner = untag_ptr(this_ptr);
31191         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31193         this_ptr_conv.is_owned = false;
31194         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31195         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
31196         return ret_arr;
31197 }
31198
31199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31200         LDKInMemorySigner this_ptr_conv;
31201         this_ptr_conv.inner = untag_ptr(this_ptr);
31202         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31204         this_ptr_conv.is_owned = false;
31205         LDKSecretKey val_ref;
31206         CHECK((*env)->GetArrayLength(env, val) == 32);
31207         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31208         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
31209 }
31210
31211 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
31212         LDKInMemorySigner this_ptr_conv;
31213         this_ptr_conv.inner = untag_ptr(this_ptr);
31214         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31216         this_ptr_conv.is_owned = false;
31217         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31218         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
31219         return ret_arr;
31220 }
31221
31222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31223         LDKInMemorySigner this_ptr_conv;
31224         this_ptr_conv.inner = untag_ptr(this_ptr);
31225         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31227         this_ptr_conv.is_owned = false;
31228         LDKThirtyTwoBytes val_ref;
31229         CHECK((*env)->GetArrayLength(env, val) == 32);
31230         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31231         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
31232 }
31233
31234 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
31235         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
31236         int64_t ret_ref = 0;
31237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31238         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31239         return ret_ref;
31240 }
31241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31242         LDKInMemorySigner arg_conv;
31243         arg_conv.inner = untag_ptr(arg);
31244         arg_conv.is_owned = ptr_is_owned(arg);
31245         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31246         arg_conv.is_owned = false;
31247         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
31248         return ret_conv;
31249 }
31250
31251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31252         LDKInMemorySigner orig_conv;
31253         orig_conv.inner = untag_ptr(orig);
31254         orig_conv.is_owned = ptr_is_owned(orig);
31255         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31256         orig_conv.is_owned = false;
31257         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
31258         int64_t ret_ref = 0;
31259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31260         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31261         return ret_ref;
31262 }
31263
31264 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) {
31265         LDKSecretKey funding_key_ref;
31266         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
31267         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
31268         LDKSecretKey revocation_base_key_ref;
31269         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
31270         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
31271         LDKSecretKey payment_key_ref;
31272         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
31273         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
31274         LDKSecretKey delayed_payment_base_key_ref;
31275         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
31276         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
31277         LDKSecretKey htlc_base_key_ref;
31278         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
31279         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
31280         LDKThirtyTwoBytes commitment_seed_ref;
31281         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
31282         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
31283         LDKThirtyTwoBytes channel_keys_id_ref;
31284         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
31285         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
31286         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);
31287         int64_t ret_ref = 0;
31288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31289         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31290         return ret_ref;
31291 }
31292
31293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
31294         LDKInMemorySigner this_arg_conv;
31295         this_arg_conv.inner = untag_ptr(this_arg);
31296         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31298         this_arg_conv.is_owned = false;
31299         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
31300         int64_t ret_ref = 0;
31301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31302         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31303         return ret_ref;
31304 }
31305
31306 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
31307         LDKInMemorySigner this_arg_conv;
31308         this_arg_conv.inner = untag_ptr(this_arg);
31309         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31311         this_arg_conv.is_owned = false;
31312         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
31313         return ret_conv;
31314 }
31315
31316 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
31317         LDKInMemorySigner this_arg_conv;
31318         this_arg_conv.inner = untag_ptr(this_arg);
31319         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31321         this_arg_conv.is_owned = false;
31322         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
31323         return ret_conv;
31324 }
31325
31326 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
31327         LDKInMemorySigner this_arg_conv;
31328         this_arg_conv.inner = untag_ptr(this_arg);
31329         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31331         this_arg_conv.is_owned = false;
31332         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
31333         return ret_conv;
31334 }
31335
31336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
31337         LDKInMemorySigner this_arg_conv;
31338         this_arg_conv.inner = untag_ptr(this_arg);
31339         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31341         this_arg_conv.is_owned = false;
31342         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
31343         int64_t ret_ref = 0;
31344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31345         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31346         return ret_ref;
31347 }
31348
31349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
31350         LDKInMemorySigner this_arg_conv;
31351         this_arg_conv.inner = untag_ptr(this_arg);
31352         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31354         this_arg_conv.is_owned = false;
31355         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
31356         int64_t ret_ref = 0;
31357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31358         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31359         return ret_ref;
31360 }
31361
31362 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
31363         LDKInMemorySigner this_arg_conv;
31364         this_arg_conv.inner = untag_ptr(this_arg);
31365         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31367         this_arg_conv.is_owned = false;
31368         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
31369         return ret_conv;
31370 }
31371
31372 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) {
31373         LDKInMemorySigner this_arg_conv;
31374         this_arg_conv.inner = untag_ptr(this_arg);
31375         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31377         this_arg_conv.is_owned = false;
31378         LDKTransaction spend_tx_ref;
31379         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
31380         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
31381         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
31382         spend_tx_ref.data_is_owned = true;
31383         LDKStaticPaymentOutputDescriptor descriptor_conv;
31384         descriptor_conv.inner = untag_ptr(descriptor);
31385         descriptor_conv.is_owned = ptr_is_owned(descriptor);
31386         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
31387         descriptor_conv.is_owned = false;
31388         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
31389         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
31390         return tag_ptr(ret_conv, true);
31391 }
31392
31393 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) {
31394         LDKInMemorySigner this_arg_conv;
31395         this_arg_conv.inner = untag_ptr(this_arg);
31396         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31398         this_arg_conv.is_owned = false;
31399         LDKTransaction spend_tx_ref;
31400         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
31401         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
31402         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
31403         spend_tx_ref.data_is_owned = true;
31404         LDKDelayedPaymentOutputDescriptor descriptor_conv;
31405         descriptor_conv.inner = untag_ptr(descriptor);
31406         descriptor_conv.is_owned = ptr_is_owned(descriptor);
31407         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
31408         descriptor_conv.is_owned = false;
31409         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
31410         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
31411         return tag_ptr(ret_conv, true);
31412 }
31413
31414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1ChannelSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31415         LDKInMemorySigner this_arg_conv;
31416         this_arg_conv.inner = untag_ptr(this_arg);
31417         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31419         this_arg_conv.is_owned = false;
31420         LDKChannelSigner* ret_ret = MALLOC(sizeof(LDKChannelSigner), "LDKChannelSigner");
31421         *ret_ret = InMemorySigner_as_ChannelSigner(&this_arg_conv);
31422         return tag_ptr(ret_ret, true);
31423 }
31424
31425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1EcdsaChannelSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31426         LDKInMemorySigner this_arg_conv;
31427         this_arg_conv.inner = untag_ptr(this_arg);
31428         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31430         this_arg_conv.is_owned = false;
31431         LDKEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKEcdsaChannelSigner), "LDKEcdsaChannelSigner");
31432         *ret_ret = InMemorySigner_as_EcdsaChannelSigner(&this_arg_conv);
31433         return tag_ptr(ret_ret, true);
31434 }
31435
31436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1WriteableEcdsaChannelSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31437         LDKInMemorySigner this_arg_conv;
31438         this_arg_conv.inner = untag_ptr(this_arg);
31439         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31441         this_arg_conv.is_owned = false;
31442         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
31443         *ret_ret = InMemorySigner_as_WriteableEcdsaChannelSigner(&this_arg_conv);
31444         return tag_ptr(ret_ret, true);
31445 }
31446
31447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
31448         LDKInMemorySigner obj_conv;
31449         obj_conv.inner = untag_ptr(obj);
31450         obj_conv.is_owned = ptr_is_owned(obj);
31451         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31452         obj_conv.is_owned = false;
31453         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
31454         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31455         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31456         CVec_u8Z_free(ret_var);
31457         return ret_arr;
31458 }
31459
31460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31461         LDKu8slice ser_ref;
31462         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31463         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31464         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
31465         *ret_conv = InMemorySigner_read(ser_ref);
31466         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31467         return tag_ptr(ret_conv, true);
31468 }
31469
31470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31471         LDKKeysManager this_obj_conv;
31472         this_obj_conv.inner = untag_ptr(this_obj);
31473         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31475         KeysManager_free(this_obj_conv);
31476 }
31477
31478 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) {
31479         uint8_t seed_arr[32];
31480         CHECK((*env)->GetArrayLength(env, seed) == 32);
31481         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
31482         uint8_t (*seed_ref)[32] = &seed_arr;
31483         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
31484         int64_t ret_ref = 0;
31485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31486         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31487         return ret_ref;
31488 }
31489
31490 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysManager_1get_1node_1secret_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31491         LDKKeysManager this_arg_conv;
31492         this_arg_conv.inner = untag_ptr(this_arg);
31493         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31495         this_arg_conv.is_owned = false;
31496         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31497         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, KeysManager_get_node_secret_key(&this_arg_conv).bytes);
31498         return ret_arr;
31499 }
31500
31501 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) {
31502         LDKKeysManager this_arg_conv;
31503         this_arg_conv.inner = untag_ptr(this_arg);
31504         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31506         this_arg_conv.is_owned = false;
31507         uint8_t params_arr[32];
31508         CHECK((*env)->GetArrayLength(env, params) == 32);
31509         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
31510         uint8_t (*params_ref)[32] = &params_arr;
31511         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
31512         int64_t ret_ref = 0;
31513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31514         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31515         return ret_ref;
31516 }
31517
31518 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) {
31519         LDKKeysManager this_arg_conv;
31520         this_arg_conv.inner = untag_ptr(this_arg);
31521         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31523         this_arg_conv.is_owned = false;
31524         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
31525         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
31526         if (descriptors_constr.datalen > 0)
31527                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
31528         else
31529                 descriptors_constr.data = NULL;
31530         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
31531         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
31532                 int64_t descriptors_conv_27 = descriptors_vals[b];
31533                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
31534                 CHECK_ACCESS(descriptors_conv_27_ptr);
31535                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
31536                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
31537                 descriptors_constr.data[b] = descriptors_conv_27_conv;
31538         }
31539         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
31540         LDKCVec_TxOutZ outputs_constr;
31541         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
31542         if (outputs_constr.datalen > 0)
31543                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
31544         else
31545                 outputs_constr.data = NULL;
31546         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
31547         for (size_t h = 0; h < outputs_constr.datalen; h++) {
31548                 int64_t outputs_conv_7 = outputs_vals[h];
31549                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
31550                 CHECK_ACCESS(outputs_conv_7_ptr);
31551                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
31552                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
31553                 outputs_constr.data[h] = outputs_conv_7_conv;
31554         }
31555         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
31556         LDKCVec_u8Z change_destination_script_ref;
31557         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
31558         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
31559         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
31560         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
31561         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
31562         return tag_ptr(ret_conv, true);
31563 }
31564
31565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1EntropySource(JNIEnv *env, jclass clz, int64_t this_arg) {
31566         LDKKeysManager this_arg_conv;
31567         this_arg_conv.inner = untag_ptr(this_arg);
31568         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31570         this_arg_conv.is_owned = false;
31571         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
31572         *ret_ret = KeysManager_as_EntropySource(&this_arg_conv);
31573         return tag_ptr(ret_ret, true);
31574 }
31575
31576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1NodeSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31577         LDKKeysManager this_arg_conv;
31578         this_arg_conv.inner = untag_ptr(this_arg);
31579         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31581         this_arg_conv.is_owned = false;
31582         LDKNodeSigner* ret_ret = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
31583         *ret_ret = KeysManager_as_NodeSigner(&this_arg_conv);
31584         return tag_ptr(ret_ret, true);
31585 }
31586
31587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1SignerProvider(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         LDKSignerProvider* ret_ret = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
31594         *ret_ret = KeysManager_as_SignerProvider(&this_arg_conv);
31595         return tag_ptr(ret_ret, true);
31596 }
31597
31598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31599         LDKPhantomKeysManager this_obj_conv;
31600         this_obj_conv.inner = untag_ptr(this_obj);
31601         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31603         PhantomKeysManager_free(this_obj_conv);
31604 }
31605
31606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1EntropySource(JNIEnv *env, jclass clz, int64_t this_arg) {
31607         LDKPhantomKeysManager this_arg_conv;
31608         this_arg_conv.inner = untag_ptr(this_arg);
31609         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31611         this_arg_conv.is_owned = false;
31612         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
31613         *ret_ret = PhantomKeysManager_as_EntropySource(&this_arg_conv);
31614         return tag_ptr(ret_ret, true);
31615 }
31616
31617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1NodeSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31618         LDKPhantomKeysManager this_arg_conv;
31619         this_arg_conv.inner = untag_ptr(this_arg);
31620         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31622         this_arg_conv.is_owned = false;
31623         LDKNodeSigner* ret_ret = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
31624         *ret_ret = PhantomKeysManager_as_NodeSigner(&this_arg_conv);
31625         return tag_ptr(ret_ret, true);
31626 }
31627
31628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1SignerProvider(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         LDKSignerProvider* ret_ret = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
31635         *ret_ret = PhantomKeysManager_as_SignerProvider(&this_arg_conv);
31636         return tag_ptr(ret_ret, true);
31637 }
31638
31639 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) {
31640         uint8_t seed_arr[32];
31641         CHECK((*env)->GetArrayLength(env, seed) == 32);
31642         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
31643         uint8_t (*seed_ref)[32] = &seed_arr;
31644         uint8_t cross_node_seed_arr[32];
31645         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
31646         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
31647         uint8_t (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
31648         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
31649         int64_t ret_ref = 0;
31650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31651         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31652         return ret_ref;
31653 }
31654
31655 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) {
31656         LDKPhantomKeysManager this_arg_conv;
31657         this_arg_conv.inner = untag_ptr(this_arg);
31658         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31660         this_arg_conv.is_owned = false;
31661         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
31662         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
31663         if (descriptors_constr.datalen > 0)
31664                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
31665         else
31666                 descriptors_constr.data = NULL;
31667         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
31668         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
31669                 int64_t descriptors_conv_27 = descriptors_vals[b];
31670                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
31671                 CHECK_ACCESS(descriptors_conv_27_ptr);
31672                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
31673                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
31674                 descriptors_constr.data[b] = descriptors_conv_27_conv;
31675         }
31676         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
31677         LDKCVec_TxOutZ outputs_constr;
31678         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
31679         if (outputs_constr.datalen > 0)
31680                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
31681         else
31682                 outputs_constr.data = NULL;
31683         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
31684         for (size_t h = 0; h < outputs_constr.datalen; h++) {
31685                 int64_t outputs_conv_7 = outputs_vals[h];
31686                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
31687                 CHECK_ACCESS(outputs_conv_7_ptr);
31688                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
31689                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
31690                 outputs_constr.data[h] = outputs_conv_7_conv;
31691         }
31692         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
31693         LDKCVec_u8Z change_destination_script_ref;
31694         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
31695         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
31696         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
31697         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
31698         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
31699         return tag_ptr(ret_conv, true);
31700 }
31701
31702 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) {
31703         LDKPhantomKeysManager this_arg_conv;
31704         this_arg_conv.inner = untag_ptr(this_arg);
31705         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31707         this_arg_conv.is_owned = false;
31708         uint8_t params_arr[32];
31709         CHECK((*env)->GetArrayLength(env, params) == 32);
31710         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
31711         uint8_t (*params_ref)[32] = &params_arr;
31712         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
31713         int64_t ret_ref = 0;
31714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31715         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31716         return ret_ref;
31717 }
31718
31719 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1get_1node_1secret_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31720         LDKPhantomKeysManager this_arg_conv;
31721         this_arg_conv.inner = untag_ptr(this_arg);
31722         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31724         this_arg_conv.is_owned = false;
31725         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31726         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, PhantomKeysManager_get_node_secret_key(&this_arg_conv).bytes);
31727         return ret_arr;
31728 }
31729
31730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1get_1phantom_1node_1secret_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31731         LDKPhantomKeysManager this_arg_conv;
31732         this_arg_conv.inner = untag_ptr(this_arg);
31733         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31735         this_arg_conv.is_owned = false;
31736         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31737         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, PhantomKeysManager_get_phantom_node_secret_key(&this_arg_conv).bytes);
31738         return ret_arr;
31739 }
31740
31741 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31742         LDKFailureCode* orig_conv = (LDKFailureCode*)untag_ptr(orig);
31743         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_clone(orig_conv));
31744         return ret_conv;
31745 }
31746
31747 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1temporary_1node_1failure(JNIEnv *env, jclass clz) {
31748         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_temporary_node_failure());
31749         return ret_conv;
31750 }
31751
31752 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1required_1node_1feature_1missing(JNIEnv *env, jclass clz) {
31753         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_required_node_feature_missing());
31754         return ret_conv;
31755 }
31756
31757 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1incorrect_1or_1unknown_1payment_1details(JNIEnv *env, jclass clz) {
31758         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_incorrect_or_unknown_payment_details());
31759         return ret_conv;
31760 }
31761
31762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31763         LDKChannelManager this_obj_conv;
31764         this_obj_conv.inner = untag_ptr(this_obj);
31765         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31767         ChannelManager_free(this_obj_conv);
31768 }
31769
31770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31771         LDKChainParameters this_obj_conv;
31772         this_obj_conv.inner = untag_ptr(this_obj);
31773         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31775         ChainParameters_free(this_obj_conv);
31776 }
31777
31778 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
31779         LDKChainParameters this_ptr_conv;
31780         this_ptr_conv.inner = untag_ptr(this_ptr);
31781         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31783         this_ptr_conv.is_owned = false;
31784         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
31785         return ret_conv;
31786 }
31787
31788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
31789         LDKChainParameters this_ptr_conv;
31790         this_ptr_conv.inner = untag_ptr(this_ptr);
31791         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31793         this_ptr_conv.is_owned = false;
31794         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
31795         ChainParameters_set_network(&this_ptr_conv, val_conv);
31796 }
31797
31798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
31799         LDKChainParameters this_ptr_conv;
31800         this_ptr_conv.inner = untag_ptr(this_ptr);
31801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31803         this_ptr_conv.is_owned = false;
31804         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
31805         int64_t ret_ref = 0;
31806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31807         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31808         return ret_ref;
31809 }
31810
31811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31812         LDKChainParameters this_ptr_conv;
31813         this_ptr_conv.inner = untag_ptr(this_ptr);
31814         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31816         this_ptr_conv.is_owned = false;
31817         LDKBestBlock val_conv;
31818         val_conv.inner = untag_ptr(val);
31819         val_conv.is_owned = ptr_is_owned(val);
31820         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31821         val_conv = BestBlock_clone(&val_conv);
31822         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
31823 }
31824
31825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
31826         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
31827         LDKBestBlock best_block_arg_conv;
31828         best_block_arg_conv.inner = untag_ptr(best_block_arg);
31829         best_block_arg_conv.is_owned = ptr_is_owned(best_block_arg);
31830         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
31831         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
31832         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
31833         int64_t ret_ref = 0;
31834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31835         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31836         return ret_ref;
31837 }
31838
31839 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
31840         LDKChainParameters ret_var = ChainParameters_clone(arg);
31841         int64_t ret_ref = 0;
31842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31843         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31844         return ret_ref;
31845 }
31846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31847         LDKChainParameters arg_conv;
31848         arg_conv.inner = untag_ptr(arg);
31849         arg_conv.is_owned = ptr_is_owned(arg);
31850         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31851         arg_conv.is_owned = false;
31852         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
31853         return ret_conv;
31854 }
31855
31856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31857         LDKChainParameters orig_conv;
31858         orig_conv.inner = untag_ptr(orig);
31859         orig_conv.is_owned = ptr_is_owned(orig);
31860         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31861         orig_conv.is_owned = false;
31862         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
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
31869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31870         LDKCounterpartyForwardingInfo this_obj_conv;
31871         this_obj_conv.inner = untag_ptr(this_obj);
31872         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31874         CounterpartyForwardingInfo_free(this_obj_conv);
31875 }
31876
31877 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31878         LDKCounterpartyForwardingInfo this_ptr_conv;
31879         this_ptr_conv.inner = untag_ptr(this_ptr);
31880         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31882         this_ptr_conv.is_owned = false;
31883         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
31884         return ret_conv;
31885 }
31886
31887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31888         LDKCounterpartyForwardingInfo this_ptr_conv;
31889         this_ptr_conv.inner = untag_ptr(this_ptr);
31890         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31892         this_ptr_conv.is_owned = false;
31893         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
31894 }
31895
31896 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
31897         LDKCounterpartyForwardingInfo this_ptr_conv;
31898         this_ptr_conv.inner = untag_ptr(this_ptr);
31899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31901         this_ptr_conv.is_owned = false;
31902         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
31903         return ret_conv;
31904 }
31905
31906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31907         LDKCounterpartyForwardingInfo this_ptr_conv;
31908         this_ptr_conv.inner = untag_ptr(this_ptr);
31909         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31911         this_ptr_conv.is_owned = false;
31912         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
31913 }
31914
31915 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
31916         LDKCounterpartyForwardingInfo this_ptr_conv;
31917         this_ptr_conv.inner = untag_ptr(this_ptr);
31918         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31920         this_ptr_conv.is_owned = false;
31921         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
31922         return ret_conv;
31923 }
31924
31925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31926         LDKCounterpartyForwardingInfo this_ptr_conv;
31927         this_ptr_conv.inner = untag_ptr(this_ptr);
31928         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31930         this_ptr_conv.is_owned = false;
31931         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
31932 }
31933
31934 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) {
31935         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
31936         int64_t ret_ref = 0;
31937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31938         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31939         return ret_ref;
31940 }
31941
31942 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
31943         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
31944         int64_t ret_ref = 0;
31945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31946         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31947         return ret_ref;
31948 }
31949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31950         LDKCounterpartyForwardingInfo arg_conv;
31951         arg_conv.inner = untag_ptr(arg);
31952         arg_conv.is_owned = ptr_is_owned(arg);
31953         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31954         arg_conv.is_owned = false;
31955         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
31956         return ret_conv;
31957 }
31958
31959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31960         LDKCounterpartyForwardingInfo orig_conv;
31961         orig_conv.inner = untag_ptr(orig);
31962         orig_conv.is_owned = ptr_is_owned(orig);
31963         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31964         orig_conv.is_owned = false;
31965         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
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
31972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31973         LDKChannelCounterparty this_obj_conv;
31974         this_obj_conv.inner = untag_ptr(this_obj);
31975         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31977         ChannelCounterparty_free(this_obj_conv);
31978 }
31979
31980 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31981         LDKChannelCounterparty this_ptr_conv;
31982         this_ptr_conv.inner = untag_ptr(this_ptr);
31983         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31985         this_ptr_conv.is_owned = false;
31986         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31987         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
31988         return ret_arr;
31989 }
31990
31991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31992         LDKChannelCounterparty this_ptr_conv;
31993         this_ptr_conv.inner = untag_ptr(this_ptr);
31994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31996         this_ptr_conv.is_owned = false;
31997         LDKPublicKey val_ref;
31998         CHECK((*env)->GetArrayLength(env, val) == 33);
31999         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32000         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
32001 }
32002
32003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
32004         LDKChannelCounterparty this_ptr_conv;
32005         this_ptr_conv.inner = untag_ptr(this_ptr);
32006         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32008         this_ptr_conv.is_owned = false;
32009         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
32010         int64_t ret_ref = 0;
32011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32012         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32013         return ret_ref;
32014 }
32015
32016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32017         LDKChannelCounterparty this_ptr_conv;
32018         this_ptr_conv.inner = untag_ptr(this_ptr);
32019         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32021         this_ptr_conv.is_owned = false;
32022         LDKInitFeatures val_conv;
32023         val_conv.inner = untag_ptr(val);
32024         val_conv.is_owned = ptr_is_owned(val);
32025         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32026         val_conv = InitFeatures_clone(&val_conv);
32027         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
32028 }
32029
32030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
32031         LDKChannelCounterparty this_ptr_conv;
32032         this_ptr_conv.inner = untag_ptr(this_ptr);
32033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32035         this_ptr_conv.is_owned = false;
32036         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
32037         return ret_conv;
32038 }
32039
32040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32041         LDKChannelCounterparty this_ptr_conv;
32042         this_ptr_conv.inner = untag_ptr(this_ptr);
32043         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32045         this_ptr_conv.is_owned = false;
32046         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
32047 }
32048
32049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
32050         LDKChannelCounterparty this_ptr_conv;
32051         this_ptr_conv.inner = untag_ptr(this_ptr);
32052         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32054         this_ptr_conv.is_owned = false;
32055         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
32056         int64_t ret_ref = 0;
32057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32058         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32059         return ret_ref;
32060 }
32061
32062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(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         LDKCounterpartyForwardingInfo val_conv;
32069         val_conv.inner = untag_ptr(val);
32070         val_conv.is_owned = ptr_is_owned(val);
32071         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32072         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
32073         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
32074 }
32075
32076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32077         LDKChannelCounterparty this_ptr_conv;
32078         this_ptr_conv.inner = untag_ptr(this_ptr);
32079         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32081         this_ptr_conv.is_owned = false;
32082         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32083         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
32084         int64_t ret_ref = tag_ptr(ret_copy, true);
32085         return ret_ref;
32086 }
32087
32088 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) {
32089         LDKChannelCounterparty this_ptr_conv;
32090         this_ptr_conv.inner = untag_ptr(this_ptr);
32091         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32093         this_ptr_conv.is_owned = false;
32094         void* val_ptr = untag_ptr(val);
32095         CHECK_ACCESS(val_ptr);
32096         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32097         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32098         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
32099 }
32100
32101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32102         LDKChannelCounterparty this_ptr_conv;
32103         this_ptr_conv.inner = untag_ptr(this_ptr);
32104         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32106         this_ptr_conv.is_owned = false;
32107         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32108         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
32109         int64_t ret_ref = tag_ptr(ret_copy, true);
32110         return ret_ref;
32111 }
32112
32113 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) {
32114         LDKChannelCounterparty this_ptr_conv;
32115         this_ptr_conv.inner = untag_ptr(this_ptr);
32116         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32118         this_ptr_conv.is_owned = false;
32119         void* val_ptr = untag_ptr(val);
32120         CHECK_ACCESS(val_ptr);
32121         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32122         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32123         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
32124 }
32125
32126 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) {
32127         LDKPublicKey node_id_arg_ref;
32128         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
32129         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
32130         LDKInitFeatures features_arg_conv;
32131         features_arg_conv.inner = untag_ptr(features_arg);
32132         features_arg_conv.is_owned = ptr_is_owned(features_arg);
32133         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
32134         features_arg_conv = InitFeatures_clone(&features_arg_conv);
32135         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
32136         forwarding_info_arg_conv.inner = untag_ptr(forwarding_info_arg);
32137         forwarding_info_arg_conv.is_owned = ptr_is_owned(forwarding_info_arg);
32138         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
32139         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
32140         void* outbound_htlc_minimum_msat_arg_ptr = untag_ptr(outbound_htlc_minimum_msat_arg);
32141         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
32142         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
32143         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_minimum_msat_arg));
32144         void* outbound_htlc_maximum_msat_arg_ptr = untag_ptr(outbound_htlc_maximum_msat_arg);
32145         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
32146         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
32147         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_maximum_msat_arg));
32148         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);
32149         int64_t ret_ref = 0;
32150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32151         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32152         return ret_ref;
32153 }
32154
32155 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
32156         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
32157         int64_t ret_ref = 0;
32158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32159         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32160         return ret_ref;
32161 }
32162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32163         LDKChannelCounterparty arg_conv;
32164         arg_conv.inner = untag_ptr(arg);
32165         arg_conv.is_owned = ptr_is_owned(arg);
32166         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32167         arg_conv.is_owned = false;
32168         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
32169         return ret_conv;
32170 }
32171
32172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32173         LDKChannelCounterparty orig_conv;
32174         orig_conv.inner = untag_ptr(orig);
32175         orig_conv.is_owned = ptr_is_owned(orig);
32176         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32177         orig_conv.is_owned = false;
32178         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
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
32185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32186         LDKChannelDetails this_obj_conv;
32187         this_obj_conv.inner = untag_ptr(this_obj);
32188         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32190         ChannelDetails_free(this_obj_conv);
32191 }
32192
32193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32194         LDKChannelDetails this_ptr_conv;
32195         this_ptr_conv.inner = untag_ptr(this_ptr);
32196         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32198         this_ptr_conv.is_owned = false;
32199         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32200         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
32201         return ret_arr;
32202 }
32203
32204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32205         LDKChannelDetails this_ptr_conv;
32206         this_ptr_conv.inner = untag_ptr(this_ptr);
32207         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32209         this_ptr_conv.is_owned = false;
32210         LDKThirtyTwoBytes val_ref;
32211         CHECK((*env)->GetArrayLength(env, val) == 32);
32212         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32213         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
32214 }
32215
32216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
32217         LDKChannelDetails this_ptr_conv;
32218         this_ptr_conv.inner = untag_ptr(this_ptr);
32219         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32221         this_ptr_conv.is_owned = false;
32222         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
32223         int64_t ret_ref = 0;
32224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32225         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32226         return ret_ref;
32227 }
32228
32229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32230         LDKChannelDetails this_ptr_conv;
32231         this_ptr_conv.inner = untag_ptr(this_ptr);
32232         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32234         this_ptr_conv.is_owned = false;
32235         LDKChannelCounterparty val_conv;
32236         val_conv.inner = untag_ptr(val);
32237         val_conv.is_owned = ptr_is_owned(val);
32238         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32239         val_conv = ChannelCounterparty_clone(&val_conv);
32240         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
32241 }
32242
32243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
32244         LDKChannelDetails this_ptr_conv;
32245         this_ptr_conv.inner = untag_ptr(this_ptr);
32246         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32248         this_ptr_conv.is_owned = false;
32249         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
32250         int64_t ret_ref = 0;
32251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32252         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32253         return ret_ref;
32254 }
32255
32256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32257         LDKChannelDetails this_ptr_conv;
32258         this_ptr_conv.inner = untag_ptr(this_ptr);
32259         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32261         this_ptr_conv.is_owned = false;
32262         LDKOutPoint val_conv;
32263         val_conv.inner = untag_ptr(val);
32264         val_conv.is_owned = ptr_is_owned(val);
32265         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32266         val_conv = OutPoint_clone(&val_conv);
32267         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
32268 }
32269
32270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
32271         LDKChannelDetails this_ptr_conv;
32272         this_ptr_conv.inner = untag_ptr(this_ptr);
32273         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32275         this_ptr_conv.is_owned = false;
32276         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
32277         int64_t ret_ref = 0;
32278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32279         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32280         return ret_ref;
32281 }
32282
32283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32284         LDKChannelDetails this_ptr_conv;
32285         this_ptr_conv.inner = untag_ptr(this_ptr);
32286         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32288         this_ptr_conv.is_owned = false;
32289         LDKChannelTypeFeatures val_conv;
32290         val_conv.inner = untag_ptr(val);
32291         val_conv.is_owned = ptr_is_owned(val);
32292         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32293         val_conv = ChannelTypeFeatures_clone(&val_conv);
32294         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
32295 }
32296
32297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32298         LDKChannelDetails this_ptr_conv;
32299         this_ptr_conv.inner = untag_ptr(this_ptr);
32300         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32302         this_ptr_conv.is_owned = false;
32303         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32304         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
32305         int64_t ret_ref = tag_ptr(ret_copy, true);
32306         return ret_ref;
32307 }
32308
32309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32310         LDKChannelDetails this_ptr_conv;
32311         this_ptr_conv.inner = untag_ptr(this_ptr);
32312         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32314         this_ptr_conv.is_owned = false;
32315         void* val_ptr = untag_ptr(val);
32316         CHECK_ACCESS(val_ptr);
32317         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32318         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32319         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
32320 }
32321
32322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
32323         LDKChannelDetails this_ptr_conv;
32324         this_ptr_conv.inner = untag_ptr(this_ptr);
32325         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32327         this_ptr_conv.is_owned = false;
32328         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32329         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
32330         int64_t ret_ref = tag_ptr(ret_copy, true);
32331         return ret_ref;
32332 }
32333
32334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32335         LDKChannelDetails this_ptr_conv;
32336         this_ptr_conv.inner = untag_ptr(this_ptr);
32337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32339         this_ptr_conv.is_owned = false;
32340         void* val_ptr = untag_ptr(val);
32341         CHECK_ACCESS(val_ptr);
32342         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32343         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32344         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
32345 }
32346
32347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
32348         LDKChannelDetails this_ptr_conv;
32349         this_ptr_conv.inner = untag_ptr(this_ptr);
32350         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32352         this_ptr_conv.is_owned = false;
32353         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32354         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
32355         int64_t ret_ref = tag_ptr(ret_copy, true);
32356         return ret_ref;
32357 }
32358
32359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32360         LDKChannelDetails this_ptr_conv;
32361         this_ptr_conv.inner = untag_ptr(this_ptr);
32362         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32364         this_ptr_conv.is_owned = false;
32365         void* val_ptr = untag_ptr(val);
32366         CHECK_ACCESS(val_ptr);
32367         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32368         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32369         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
32370 }
32371
32372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32373         LDKChannelDetails this_ptr_conv;
32374         this_ptr_conv.inner = untag_ptr(this_ptr);
32375         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32377         this_ptr_conv.is_owned = false;
32378         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
32379         return ret_conv;
32380 }
32381
32382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32383         LDKChannelDetails this_ptr_conv;
32384         this_ptr_conv.inner = untag_ptr(this_ptr);
32385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32387         this_ptr_conv.is_owned = false;
32388         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
32389 }
32390
32391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
32392         LDKChannelDetails this_ptr_conv;
32393         this_ptr_conv.inner = untag_ptr(this_ptr);
32394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32396         this_ptr_conv.is_owned = false;
32397         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32398         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
32399         int64_t ret_ref = tag_ptr(ret_copy, true);
32400         return ret_ref;
32401 }
32402
32403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32404         LDKChannelDetails this_ptr_conv;
32405         this_ptr_conv.inner = untag_ptr(this_ptr);
32406         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32408         this_ptr_conv.is_owned = false;
32409         void* val_ptr = untag_ptr(val);
32410         CHECK_ACCESS(val_ptr);
32411         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32412         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32413         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
32414 }
32415
32416 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32417         LDKChannelDetails this_ptr_conv;
32418         this_ptr_conv.inner = untag_ptr(this_ptr);
32419         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32421         this_ptr_conv.is_owned = false;
32422         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
32423         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, ChannelDetails_get_user_channel_id(&this_ptr_conv).le_bytes);
32424         return ret_arr;
32425 }
32426
32427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32428         LDKChannelDetails this_ptr_conv;
32429         this_ptr_conv.inner = untag_ptr(this_ptr);
32430         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32432         this_ptr_conv.is_owned = false;
32433         LDKU128 val_ref;
32434         CHECK((*env)->GetArrayLength(env, val) == 16);
32435         (*env)->GetByteArrayRegion(env, val, 0, 16, val_ref.le_bytes);
32436         ChannelDetails_set_user_channel_id(&this_ptr_conv, val_ref);
32437 }
32438
32439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32440         LDKChannelDetails this_ptr_conv;
32441         this_ptr_conv.inner = untag_ptr(this_ptr);
32442         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32444         this_ptr_conv.is_owned = false;
32445         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
32446         return ret_conv;
32447 }
32448
32449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t 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         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
32456 }
32457
32458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32459         LDKChannelDetails this_ptr_conv;
32460         this_ptr_conv.inner = untag_ptr(this_ptr);
32461         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32463         this_ptr_conv.is_owned = false;
32464         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
32465         return ret_conv;
32466 }
32467
32468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32469         LDKChannelDetails this_ptr_conv;
32470         this_ptr_conv.inner = untag_ptr(this_ptr);
32471         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32473         this_ptr_conv.is_owned = false;
32474         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
32475 }
32476
32477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32478         LDKChannelDetails this_ptr_conv;
32479         this_ptr_conv.inner = untag_ptr(this_ptr);
32480         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32482         this_ptr_conv.is_owned = false;
32483         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
32484         return ret_conv;
32485 }
32486
32487 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) {
32488         LDKChannelDetails this_ptr_conv;
32489         this_ptr_conv.inner = untag_ptr(this_ptr);
32490         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32492         this_ptr_conv.is_owned = false;
32493         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
32494 }
32495
32496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
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         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
32503         return ret_conv;
32504 }
32505
32506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32507         LDKChannelDetails this_ptr_conv;
32508         this_ptr_conv.inner = untag_ptr(this_ptr);
32509         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32511         this_ptr_conv.is_owned = false;
32512         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
32513 }
32514
32515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
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         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32522         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
32523         int64_t ret_ref = tag_ptr(ret_copy, true);
32524         return ret_ref;
32525 }
32526
32527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32528         LDKChannelDetails this_ptr_conv;
32529         this_ptr_conv.inner = untag_ptr(this_ptr);
32530         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32532         this_ptr_conv.is_owned = false;
32533         void* val_ptr = untag_ptr(val);
32534         CHECK_ACCESS(val_ptr);
32535         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32536         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32537         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
32538 }
32539
32540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations(JNIEnv *env, jclass clz, int64_t this_ptr) {
32541         LDKChannelDetails this_ptr_conv;
32542         this_ptr_conv.inner = untag_ptr(this_ptr);
32543         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32545         this_ptr_conv.is_owned = false;
32546         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32547         *ret_copy = ChannelDetails_get_confirmations(&this_ptr_conv);
32548         int64_t ret_ref = tag_ptr(ret_copy, true);
32549         return ret_ref;
32550 }
32551
32552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32553         LDKChannelDetails this_ptr_conv;
32554         this_ptr_conv.inner = untag_ptr(this_ptr);
32555         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32557         this_ptr_conv.is_owned = false;
32558         void* val_ptr = untag_ptr(val);
32559         CHECK_ACCESS(val_ptr);
32560         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32561         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32562         ChannelDetails_set_confirmations(&this_ptr_conv, val_conv);
32563 }
32564
32565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32566         LDKChannelDetails this_ptr_conv;
32567         this_ptr_conv.inner = untag_ptr(this_ptr);
32568         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32570         this_ptr_conv.is_owned = false;
32571         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
32572         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
32573         int64_t ret_ref = tag_ptr(ret_copy, true);
32574         return ret_ref;
32575 }
32576
32577 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) {
32578         LDKChannelDetails this_ptr_conv;
32579         this_ptr_conv.inner = untag_ptr(this_ptr);
32580         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32582         this_ptr_conv.is_owned = false;
32583         void* val_ptr = untag_ptr(val);
32584         CHECK_ACCESS(val_ptr);
32585         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
32586         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
32587         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
32588 }
32589
32590 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
32591         LDKChannelDetails this_ptr_conv;
32592         this_ptr_conv.inner = untag_ptr(this_ptr);
32593         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32595         this_ptr_conv.is_owned = false;
32596         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
32597         return ret_conv;
32598 }
32599
32600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32601         LDKChannelDetails this_ptr_conv;
32602         this_ptr_conv.inner = untag_ptr(this_ptr);
32603         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32605         this_ptr_conv.is_owned = false;
32606         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
32607 }
32608
32609 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
32610         LDKChannelDetails this_ptr_conv;
32611         this_ptr_conv.inner = untag_ptr(this_ptr);
32612         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32614         this_ptr_conv.is_owned = false;
32615         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
32616         return ret_conv;
32617 }
32618
32619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32620         LDKChannelDetails this_ptr_conv;
32621         this_ptr_conv.inner = untag_ptr(this_ptr);
32622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32624         this_ptr_conv.is_owned = false;
32625         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
32626 }
32627
32628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
32629         LDKChannelDetails this_ptr_conv;
32630         this_ptr_conv.inner = untag_ptr(this_ptr);
32631         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32633         this_ptr_conv.is_owned = false;
32634         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
32635         return ret_conv;
32636 }
32637
32638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32639         LDKChannelDetails this_ptr_conv;
32640         this_ptr_conv.inner = untag_ptr(this_ptr);
32641         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32643         this_ptr_conv.is_owned = false;
32644         ChannelDetails_set_is_usable(&this_ptr_conv, val);
32645 }
32646
32647 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
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         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
32654         return ret_conv;
32655 }
32656
32657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32658         LDKChannelDetails this_ptr_conv;
32659         this_ptr_conv.inner = untag_ptr(this_ptr);
32660         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32662         this_ptr_conv.is_owned = false;
32663         ChannelDetails_set_is_public(&this_ptr_conv, val);
32664 }
32665
32666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
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         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32673         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
32674         int64_t ret_ref = tag_ptr(ret_copy, true);
32675         return ret_ref;
32676 }
32677
32678 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) {
32679         LDKChannelDetails this_ptr_conv;
32680         this_ptr_conv.inner = untag_ptr(this_ptr);
32681         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32683         this_ptr_conv.is_owned = false;
32684         void* val_ptr = untag_ptr(val);
32685         CHECK_ACCESS(val_ptr);
32686         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32687         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32688         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
32689 }
32690
32691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32692         LDKChannelDetails this_ptr_conv;
32693         this_ptr_conv.inner = untag_ptr(this_ptr);
32694         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32696         this_ptr_conv.is_owned = false;
32697         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32698         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
32699         int64_t ret_ref = tag_ptr(ret_copy, true);
32700         return ret_ref;
32701 }
32702
32703 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) {
32704         LDKChannelDetails this_ptr_conv;
32705         this_ptr_conv.inner = untag_ptr(this_ptr);
32706         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32708         this_ptr_conv.is_owned = false;
32709         void* val_ptr = untag_ptr(val);
32710         CHECK_ACCESS(val_ptr);
32711         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32712         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32713         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
32714 }
32715
32716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
32717         LDKChannelDetails this_ptr_conv;
32718         this_ptr_conv.inner = untag_ptr(this_ptr);
32719         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32721         this_ptr_conv.is_owned = false;
32722         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
32723         int64_t ret_ref = 0;
32724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32725         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32726         return ret_ref;
32727 }
32728
32729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32730         LDKChannelDetails this_ptr_conv;
32731         this_ptr_conv.inner = untag_ptr(this_ptr);
32732         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32734         this_ptr_conv.is_owned = false;
32735         LDKChannelConfig val_conv;
32736         val_conv.inner = untag_ptr(val);
32737         val_conv.is_owned = ptr_is_owned(val);
32738         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32739         val_conv = ChannelConfig_clone(&val_conv);
32740         ChannelDetails_set_config(&this_ptr_conv, val_conv);
32741 }
32742
32743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t channel_type_arg, int64_t short_channel_id_arg, int64_t outbound_scid_alias_arg, int64_t inbound_scid_alias_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int8_tArray user_channel_id_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t next_outbound_htlc_limit_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t confirmations_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_channel_ready_arg, jboolean is_usable_arg, jboolean is_public_arg, int64_t inbound_htlc_minimum_msat_arg, int64_t inbound_htlc_maximum_msat_arg, int64_t config_arg) {
32744         LDKThirtyTwoBytes channel_id_arg_ref;
32745         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32746         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32747         LDKChannelCounterparty counterparty_arg_conv;
32748         counterparty_arg_conv.inner = untag_ptr(counterparty_arg);
32749         counterparty_arg_conv.is_owned = ptr_is_owned(counterparty_arg);
32750         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
32751         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
32752         LDKOutPoint funding_txo_arg_conv;
32753         funding_txo_arg_conv.inner = untag_ptr(funding_txo_arg);
32754         funding_txo_arg_conv.is_owned = ptr_is_owned(funding_txo_arg);
32755         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
32756         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
32757         LDKChannelTypeFeatures channel_type_arg_conv;
32758         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
32759         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
32760         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
32761         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
32762         void* short_channel_id_arg_ptr = untag_ptr(short_channel_id_arg);
32763         CHECK_ACCESS(short_channel_id_arg_ptr);
32764         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
32765         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_arg));
32766         void* outbound_scid_alias_arg_ptr = untag_ptr(outbound_scid_alias_arg);
32767         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
32768         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
32769         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_scid_alias_arg));
32770         void* inbound_scid_alias_arg_ptr = untag_ptr(inbound_scid_alias_arg);
32771         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
32772         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
32773         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_scid_alias_arg));
32774         void* unspendable_punishment_reserve_arg_ptr = untag_ptr(unspendable_punishment_reserve_arg);
32775         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
32776         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
32777         LDKU128 user_channel_id_arg_ref;
32778         CHECK((*env)->GetArrayLength(env, user_channel_id_arg) == 16);
32779         (*env)->GetByteArrayRegion(env, user_channel_id_arg, 0, 16, user_channel_id_arg_ref.le_bytes);
32780         void* confirmations_required_arg_ptr = untag_ptr(confirmations_required_arg);
32781         CHECK_ACCESS(confirmations_required_arg_ptr);
32782         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
32783         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_required_arg));
32784         void* confirmations_arg_ptr = untag_ptr(confirmations_arg);
32785         CHECK_ACCESS(confirmations_arg_ptr);
32786         LDKCOption_u32Z confirmations_arg_conv = *(LDKCOption_u32Z*)(confirmations_arg_ptr);
32787         confirmations_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_arg));
32788         void* force_close_spend_delay_arg_ptr = untag_ptr(force_close_spend_delay_arg);
32789         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
32790         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
32791         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(force_close_spend_delay_arg));
32792         void* inbound_htlc_minimum_msat_arg_ptr = untag_ptr(inbound_htlc_minimum_msat_arg);
32793         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
32794         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
32795         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_minimum_msat_arg));
32796         void* inbound_htlc_maximum_msat_arg_ptr = untag_ptr(inbound_htlc_maximum_msat_arg);
32797         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
32798         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
32799         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_maximum_msat_arg));
32800         LDKChannelConfig config_arg_conv;
32801         config_arg_conv.inner = untag_ptr(config_arg);
32802         config_arg_conv.is_owned = ptr_is_owned(config_arg);
32803         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
32804         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
32805         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, channel_type_arg_conv, short_channel_id_arg_conv, outbound_scid_alias_arg_conv, inbound_scid_alias_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg_ref, balance_msat_arg, outbound_capacity_msat_arg, next_outbound_htlc_limit_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, confirmations_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_channel_ready_arg, is_usable_arg, is_public_arg, inbound_htlc_minimum_msat_arg_conv, inbound_htlc_maximum_msat_arg_conv, config_arg_conv);
32806         int64_t ret_ref = 0;
32807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32808         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32809         return ret_ref;
32810 }
32811
32812 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
32813         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
32814         int64_t ret_ref = 0;
32815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32816         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32817         return ret_ref;
32818 }
32819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32820         LDKChannelDetails arg_conv;
32821         arg_conv.inner = untag_ptr(arg);
32822         arg_conv.is_owned = ptr_is_owned(arg);
32823         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32824         arg_conv.is_owned = false;
32825         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
32826         return ret_conv;
32827 }
32828
32829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32830         LDKChannelDetails orig_conv;
32831         orig_conv.inner = untag_ptr(orig);
32832         orig_conv.is_owned = ptr_is_owned(orig);
32833         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32834         orig_conv.is_owned = false;
32835         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
32836         int64_t ret_ref = 0;
32837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32838         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32839         return ret_ref;
32840 }
32841
32842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32843         LDKChannelDetails this_arg_conv;
32844         this_arg_conv.inner = untag_ptr(this_arg);
32845         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32847         this_arg_conv.is_owned = false;
32848         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32849         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
32850         int64_t ret_ref = tag_ptr(ret_copy, true);
32851         return ret_ref;
32852 }
32853
32854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32855         LDKChannelDetails this_arg_conv;
32856         this_arg_conv.inner = untag_ptr(this_arg);
32857         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32859         this_arg_conv.is_owned = false;
32860         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32861         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
32862         int64_t ret_ref = tag_ptr(ret_copy, true);
32863         return ret_ref;
32864 }
32865
32866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32867         if (!ptr_is_owned(this_ptr)) return;
32868         void* this_ptr_ptr = untag_ptr(this_ptr);
32869         CHECK_ACCESS(this_ptr_ptr);
32870         LDKRecentPaymentDetails this_ptr_conv = *(LDKRecentPaymentDetails*)(this_ptr_ptr);
32871         FREE(untag_ptr(this_ptr));
32872         RecentPaymentDetails_free(this_ptr_conv);
32873 }
32874
32875 static inline uint64_t RecentPaymentDetails_clone_ptr(LDKRecentPaymentDetails *NONNULL_PTR arg) {
32876         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32877         *ret_copy = RecentPaymentDetails_clone(arg);
32878         int64_t ret_ref = tag_ptr(ret_copy, true);
32879         return ret_ref;
32880 }
32881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32882         LDKRecentPaymentDetails* arg_conv = (LDKRecentPaymentDetails*)untag_ptr(arg);
32883         int64_t ret_conv = RecentPaymentDetails_clone_ptr(arg_conv);
32884         return ret_conv;
32885 }
32886
32887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32888         LDKRecentPaymentDetails* orig_conv = (LDKRecentPaymentDetails*)untag_ptr(orig);
32889         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32890         *ret_copy = RecentPaymentDetails_clone(orig_conv);
32891         int64_t ret_ref = tag_ptr(ret_copy, true);
32892         return ret_ref;
32893 }
32894
32895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1pending(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t total_msat) {
32896         LDKThirtyTwoBytes payment_hash_ref;
32897         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32898         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32899         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32900         *ret_copy = RecentPaymentDetails_pending(payment_hash_ref, total_msat);
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_RecentPaymentDetails_1fulfilled(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
32906         LDKThirtyTwoBytes payment_hash_ref;
32907         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32908         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32909         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32910         *ret_copy = RecentPaymentDetails_fulfilled(payment_hash_ref);
32911         int64_t ret_ref = tag_ptr(ret_copy, true);
32912         return ret_ref;
32913 }
32914
32915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1abandoned(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
32916         LDKThirtyTwoBytes payment_hash_ref;
32917         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32918         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32919         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32920         *ret_copy = RecentPaymentDetails_abandoned(payment_hash_ref);
32921         int64_t ret_ref = tag_ptr(ret_copy, true);
32922         return ret_ref;
32923 }
32924
32925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32926         LDKPhantomRouteHints this_obj_conv;
32927         this_obj_conv.inner = untag_ptr(this_obj);
32928         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32930         PhantomRouteHints_free(this_obj_conv);
32931 }
32932
32933 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
32934         LDKPhantomRouteHints this_ptr_conv;
32935         this_ptr_conv.inner = untag_ptr(this_ptr);
32936         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32938         this_ptr_conv.is_owned = false;
32939         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
32940         int64_tArray ret_arr = NULL;
32941         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
32942         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
32943         for (size_t q = 0; q < ret_var.datalen; q++) {
32944                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
32945                 int64_t ret_conv_16_ref = 0;
32946                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
32947                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
32948                 ret_arr_ptr[q] = ret_conv_16_ref;
32949         }
32950         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
32951         FREE(ret_var.data);
32952         return ret_arr;
32953 }
32954
32955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
32956         LDKPhantomRouteHints this_ptr_conv;
32957         this_ptr_conv.inner = untag_ptr(this_ptr);
32958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32960         this_ptr_conv.is_owned = false;
32961         LDKCVec_ChannelDetailsZ val_constr;
32962         val_constr.datalen = (*env)->GetArrayLength(env, val);
32963         if (val_constr.datalen > 0)
32964                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
32965         else
32966                 val_constr.data = NULL;
32967         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
32968         for (size_t q = 0; q < val_constr.datalen; q++) {
32969                 int64_t val_conv_16 = val_vals[q];
32970                 LDKChannelDetails val_conv_16_conv;
32971                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
32972                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
32973                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
32974                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
32975                 val_constr.data[q] = val_conv_16_conv;
32976         }
32977         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
32978         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
32979 }
32980
32981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
32982         LDKPhantomRouteHints this_ptr_conv;
32983         this_ptr_conv.inner = untag_ptr(this_ptr);
32984         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32986         this_ptr_conv.is_owned = false;
32987         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
32988         return ret_conv;
32989 }
32990
32991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32992         LDKPhantomRouteHints this_ptr_conv;
32993         this_ptr_conv.inner = untag_ptr(this_ptr);
32994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32996         this_ptr_conv.is_owned = false;
32997         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
32998 }
32999
33000 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
33001         LDKPhantomRouteHints this_ptr_conv;
33002         this_ptr_conv.inner = untag_ptr(this_ptr);
33003         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33005         this_ptr_conv.is_owned = false;
33006         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33007         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
33008         return ret_arr;
33009 }
33010
33011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33012         LDKPhantomRouteHints this_ptr_conv;
33013         this_ptr_conv.inner = untag_ptr(this_ptr);
33014         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33016         this_ptr_conv.is_owned = false;
33017         LDKPublicKey val_ref;
33018         CHECK((*env)->GetArrayLength(env, val) == 33);
33019         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33020         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
33021 }
33022
33023 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) {
33024         LDKCVec_ChannelDetailsZ channels_arg_constr;
33025         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
33026         if (channels_arg_constr.datalen > 0)
33027                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
33028         else
33029                 channels_arg_constr.data = NULL;
33030         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
33031         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
33032                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
33033                 LDKChannelDetails channels_arg_conv_16_conv;
33034                 channels_arg_conv_16_conv.inner = untag_ptr(channels_arg_conv_16);
33035                 channels_arg_conv_16_conv.is_owned = ptr_is_owned(channels_arg_conv_16);
33036                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
33037                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
33038                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
33039         }
33040         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
33041         LDKPublicKey real_node_pubkey_arg_ref;
33042         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
33043         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
33044         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
33045         int64_t ret_ref = 0;
33046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33047         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33048         return ret_ref;
33049 }
33050
33051 static inline uint64_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
33052         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
33053         int64_t ret_ref = 0;
33054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33055         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33056         return ret_ref;
33057 }
33058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33059         LDKPhantomRouteHints arg_conv;
33060         arg_conv.inner = untag_ptr(arg);
33061         arg_conv.is_owned = ptr_is_owned(arg);
33062         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33063         arg_conv.is_owned = false;
33064         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
33065         return ret_conv;
33066 }
33067
33068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33069         LDKPhantomRouteHints orig_conv;
33070         orig_conv.inner = untag_ptr(orig);
33071         orig_conv.is_owned = ptr_is_owned(orig);
33072         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33073         orig_conv.is_owned = false;
33074         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
33075         int64_t ret_ref = 0;
33076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33077         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33078         return ret_ref;
33079 }
33080
33081 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) {
33082         void* fee_est_ptr = untag_ptr(fee_est);
33083         CHECK_ACCESS(fee_est_ptr);
33084         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
33085         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
33086                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33087                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
33088         }
33089         void* chain_monitor_ptr = untag_ptr(chain_monitor);
33090         CHECK_ACCESS(chain_monitor_ptr);
33091         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
33092         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
33093                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33094                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
33095         }
33096         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
33097         CHECK_ACCESS(tx_broadcaster_ptr);
33098         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
33099         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33100                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33101                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
33102         }
33103         void* router_ptr = untag_ptr(router);
33104         CHECK_ACCESS(router_ptr);
33105         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
33106         if (router_conv.free == LDKRouter_JCalls_free) {
33107                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33108                 LDKRouter_JCalls_cloned(&router_conv);
33109         }
33110         void* logger_ptr = untag_ptr(logger);
33111         CHECK_ACCESS(logger_ptr);
33112         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33113         if (logger_conv.free == LDKLogger_JCalls_free) {
33114                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33115                 LDKLogger_JCalls_cloned(&logger_conv);
33116         }
33117         void* entropy_source_ptr = untag_ptr(entropy_source);
33118         CHECK_ACCESS(entropy_source_ptr);
33119         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
33120         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
33121                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33122                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
33123         }
33124         void* node_signer_ptr = untag_ptr(node_signer);
33125         CHECK_ACCESS(node_signer_ptr);
33126         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
33127         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
33128                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33129                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
33130         }
33131         void* signer_provider_ptr = untag_ptr(signer_provider);
33132         CHECK_ACCESS(signer_provider_ptr);
33133         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
33134         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
33135                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33136                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
33137         }
33138         LDKUserConfig config_conv;
33139         config_conv.inner = untag_ptr(config);
33140         config_conv.is_owned = ptr_is_owned(config);
33141         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
33142         config_conv = UserConfig_clone(&config_conv);
33143         LDKChainParameters params_conv;
33144         params_conv.inner = untag_ptr(params);
33145         params_conv.is_owned = ptr_is_owned(params);
33146         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
33147         params_conv = ChainParameters_clone(&params_conv);
33148         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);
33149         int64_t ret_ref = 0;
33150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33151         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33152         return ret_ref;
33153 }
33154
33155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
33156         LDKChannelManager this_arg_conv;
33157         this_arg_conv.inner = untag_ptr(this_arg);
33158         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33160         this_arg_conv.is_owned = false;
33161         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
33162         int64_t ret_ref = 0;
33163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33164         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33165         return ret_ref;
33166 }
33167
33168 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) {
33169         LDKChannelManager this_arg_conv;
33170         this_arg_conv.inner = untag_ptr(this_arg);
33171         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33173         this_arg_conv.is_owned = false;
33174         LDKPublicKey their_network_key_ref;
33175         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
33176         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
33177         LDKU128 user_channel_id_ref;
33178         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33179         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33180         LDKUserConfig override_config_conv;
33181         override_config_conv.inner = untag_ptr(override_config);
33182         override_config_conv.is_owned = ptr_is_owned(override_config);
33183         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
33184         override_config_conv = UserConfig_clone(&override_config_conv);
33185         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
33186         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id_ref, override_config_conv);
33187         return tag_ptr(ret_conv, true);
33188 }
33189
33190 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
33191         LDKChannelManager this_arg_conv;
33192         this_arg_conv.inner = untag_ptr(this_arg);
33193         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33195         this_arg_conv.is_owned = false;
33196         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
33197         int64_tArray ret_arr = NULL;
33198         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33199         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33200         for (size_t q = 0; q < ret_var.datalen; q++) {
33201                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33202                 int64_t ret_conv_16_ref = 0;
33203                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33204                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33205                 ret_arr_ptr[q] = ret_conv_16_ref;
33206         }
33207         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33208         FREE(ret_var.data);
33209         return ret_arr;
33210 }
33211
33212 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
33213         LDKChannelManager this_arg_conv;
33214         this_arg_conv.inner = untag_ptr(this_arg);
33215         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33217         this_arg_conv.is_owned = false;
33218         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
33219         int64_tArray ret_arr = NULL;
33220         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33221         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33222         for (size_t q = 0; q < ret_var.datalen; q++) {
33223                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33224                 int64_t ret_conv_16_ref = 0;
33225                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33226                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33227                 ret_arr_ptr[q] = ret_conv_16_ref;
33228         }
33229         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33230         FREE(ret_var.data);
33231         return ret_arr;
33232 }
33233
33234 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1recent_1payments(JNIEnv *env, jclass clz, int64_t this_arg) {
33235         LDKChannelManager this_arg_conv;
33236         this_arg_conv.inner = untag_ptr(this_arg);
33237         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33239         this_arg_conv.is_owned = false;
33240         LDKCVec_RecentPaymentDetailsZ ret_var = ChannelManager_list_recent_payments(&this_arg_conv);
33241         int64_tArray ret_arr = NULL;
33242         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33243         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33244         for (size_t w = 0; w < ret_var.datalen; w++) {
33245                 LDKRecentPaymentDetails *ret_conv_22_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
33246                 *ret_conv_22_copy = ret_var.data[w];
33247                 int64_t ret_conv_22_ref = tag_ptr(ret_conv_22_copy, true);
33248                 ret_arr_ptr[w] = ret_conv_22_ref;
33249         }
33250         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33251         FREE(ret_var.data);
33252         return ret_arr;
33253 }
33254
33255 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) {
33256         LDKChannelManager this_arg_conv;
33257         this_arg_conv.inner = untag_ptr(this_arg);
33258         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33260         this_arg_conv.is_owned = false;
33261         uint8_t channel_id_arr[32];
33262         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33263         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33264         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33265         LDKPublicKey counterparty_node_id_ref;
33266         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33267         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33268         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33269         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
33270         return tag_ptr(ret_conv, true);
33271 }
33272
33273 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) {
33274         LDKChannelManager this_arg_conv;
33275         this_arg_conv.inner = untag_ptr(this_arg);
33276         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33278         this_arg_conv.is_owned = false;
33279         uint8_t channel_id_arr[32];
33280         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33281         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33282         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33283         LDKPublicKey counterparty_node_id_ref;
33284         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33285         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33286         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33287         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
33288         return tag_ptr(ret_conv, true);
33289 }
33290
33291 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) {
33292         LDKChannelManager this_arg_conv;
33293         this_arg_conv.inner = untag_ptr(this_arg);
33294         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33296         this_arg_conv.is_owned = false;
33297         uint8_t channel_id_arr[32];
33298         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33299         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33300         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33301         LDKPublicKey counterparty_node_id_ref;
33302         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33303         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33304         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33305         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
33306         return tag_ptr(ret_conv, true);
33307 }
33308
33309 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) {
33310         LDKChannelManager this_arg_conv;
33311         this_arg_conv.inner = untag_ptr(this_arg);
33312         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33314         this_arg_conv.is_owned = false;
33315         uint8_t channel_id_arr[32];
33316         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33317         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33318         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33319         LDKPublicKey counterparty_node_id_ref;
33320         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33321         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33322         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33323         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
33324         return tag_ptr(ret_conv, true);
33325 }
33326
33327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
33328         LDKChannelManager this_arg_conv;
33329         this_arg_conv.inner = untag_ptr(this_arg);
33330         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33332         this_arg_conv.is_owned = false;
33333         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
33334 }
33335
33336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
33337         LDKChannelManager this_arg_conv;
33338         this_arg_conv.inner = untag_ptr(this_arg);
33339         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33341         this_arg_conv.is_owned = false;
33342         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
33343 }
33344
33345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_hash, int8_tArray payment_secret, int8_tArray payment_id) {
33346         LDKChannelManager this_arg_conv;
33347         this_arg_conv.inner = untag_ptr(this_arg);
33348         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33350         this_arg_conv.is_owned = false;
33351         LDKRoute route_conv;
33352         route_conv.inner = untag_ptr(route);
33353         route_conv.is_owned = ptr_is_owned(route);
33354         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
33355         route_conv.is_owned = false;
33356         LDKThirtyTwoBytes payment_hash_ref;
33357         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33358         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33359         LDKThirtyTwoBytes payment_secret_ref;
33360         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
33361         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
33362         LDKThirtyTwoBytes payment_id_ref;
33363         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33364         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33365         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
33366         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref, payment_id_ref);
33367         return tag_ptr(ret_conv, true);
33368 }
33369
33370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment_1with_1retry(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret, int8_tArray payment_id, int64_t route_params, int64_t retry_strategy) {
33371         LDKChannelManager this_arg_conv;
33372         this_arg_conv.inner = untag_ptr(this_arg);
33373         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33375         this_arg_conv.is_owned = false;
33376         LDKThirtyTwoBytes payment_hash_ref;
33377         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33378         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33379         LDKThirtyTwoBytes payment_secret_ref;
33380         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
33381         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
33382         LDKThirtyTwoBytes payment_id_ref;
33383         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33384         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33385         LDKRouteParameters route_params_conv;
33386         route_params_conv.inner = untag_ptr(route_params);
33387         route_params_conv.is_owned = ptr_is_owned(route_params);
33388         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
33389         route_params_conv = RouteParameters_clone(&route_params_conv);
33390         void* retry_strategy_ptr = untag_ptr(retry_strategy);
33391         CHECK_ACCESS(retry_strategy_ptr);
33392         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
33393         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
33394         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
33395         *ret_conv = ChannelManager_send_payment_with_retry(&this_arg_conv, payment_hash_ref, payment_secret_ref, payment_id_ref, route_params_conv, retry_strategy_conv);
33396         return tag_ptr(ret_conv, true);
33397 }
33398
33399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
33400         LDKChannelManager this_arg_conv;
33401         this_arg_conv.inner = untag_ptr(this_arg);
33402         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33404         this_arg_conv.is_owned = false;
33405         LDKThirtyTwoBytes payment_id_ref;
33406         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33407         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33408         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
33409 }
33410
33411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1spontaneous_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_preimage, int8_tArray payment_id) {
33412         LDKChannelManager this_arg_conv;
33413         this_arg_conv.inner = untag_ptr(this_arg);
33414         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33416         this_arg_conv.is_owned = false;
33417         LDKRoute route_conv;
33418         route_conv.inner = untag_ptr(route);
33419         route_conv.is_owned = ptr_is_owned(route);
33420         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
33421         route_conv.is_owned = false;
33422         LDKThirtyTwoBytes payment_preimage_ref;
33423         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33424         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33425         LDKThirtyTwoBytes payment_id_ref;
33426         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33427         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33428         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
33429         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref, payment_id_ref);
33430         return tag_ptr(ret_conv, true);
33431 }
33432
33433 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, int8_tArray payment_id, int64_t route_params, int64_t retry_strategy) {
33434         LDKChannelManager this_arg_conv;
33435         this_arg_conv.inner = untag_ptr(this_arg);
33436         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33438         this_arg_conv.is_owned = false;
33439         LDKThirtyTwoBytes payment_preimage_ref;
33440         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33441         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33442         LDKThirtyTwoBytes payment_id_ref;
33443         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33444         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33445         LDKRouteParameters route_params_conv;
33446         route_params_conv.inner = untag_ptr(route_params);
33447         route_params_conv.is_owned = ptr_is_owned(route_params);
33448         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
33449         route_params_conv = RouteParameters_clone(&route_params_conv);
33450         void* retry_strategy_ptr = untag_ptr(retry_strategy);
33451         CHECK_ACCESS(retry_strategy_ptr);
33452         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
33453         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
33454         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
33455         *ret_conv = ChannelManager_send_spontaneous_payment_with_retry(&this_arg_conv, payment_preimage_ref, payment_id_ref, route_params_conv, retry_strategy_conv);
33456         return tag_ptr(ret_conv, true);
33457 }
33458
33459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1probe(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray hops) {
33460         LDKChannelManager this_arg_conv;
33461         this_arg_conv.inner = untag_ptr(this_arg);
33462         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33464         this_arg_conv.is_owned = false;
33465         LDKCVec_RouteHopZ hops_constr;
33466         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
33467         if (hops_constr.datalen > 0)
33468                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
33469         else
33470                 hops_constr.data = NULL;
33471         int64_t* hops_vals = (*env)->GetLongArrayElements (env, hops, NULL);
33472         for (size_t k = 0; k < hops_constr.datalen; k++) {
33473                 int64_t hops_conv_10 = hops_vals[k];
33474                 LDKRouteHop hops_conv_10_conv;
33475                 hops_conv_10_conv.inner = untag_ptr(hops_conv_10);
33476                 hops_conv_10_conv.is_owned = ptr_is_owned(hops_conv_10);
33477                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv_10_conv);
33478                 hops_conv_10_conv = RouteHop_clone(&hops_conv_10_conv);
33479                 hops_constr.data[k] = hops_conv_10_conv;
33480         }
33481         (*env)->ReleaseLongArrayElements(env, hops, hops_vals, 0);
33482         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
33483         *ret_conv = ChannelManager_send_probe(&this_arg_conv, hops_constr);
33484         return tag_ptr(ret_conv, true);
33485 }
33486
33487 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) {
33488         LDKChannelManager this_arg_conv;
33489         this_arg_conv.inner = untag_ptr(this_arg);
33490         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33492         this_arg_conv.is_owned = false;
33493         uint8_t temporary_channel_id_arr[32];
33494         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33495         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33496         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33497         LDKPublicKey counterparty_node_id_ref;
33498         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33499         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33500         LDKTransaction funding_transaction_ref;
33501         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
33502         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
33503         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
33504         funding_transaction_ref.data_is_owned = true;
33505         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33506         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
33507         return tag_ptr(ret_conv, true);
33508 }
33509
33510 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) {
33511         LDKChannelManager this_arg_conv;
33512         this_arg_conv.inner = untag_ptr(this_arg);
33513         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33515         this_arg_conv.is_owned = false;
33516         LDKPublicKey counterparty_node_id_ref;
33517         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33518         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33519         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
33520         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
33521         if (channel_ids_constr.datalen > 0)
33522                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
33523         else
33524                 channel_ids_constr.data = NULL;
33525         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
33526                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
33527                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
33528                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
33529                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
33530                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
33531         }
33532         LDKChannelConfig config_conv;
33533         config_conv.inner = untag_ptr(config);
33534         config_conv.is_owned = ptr_is_owned(config);
33535         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
33536         config_conv.is_owned = false;
33537         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33538         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
33539         return tag_ptr(ret_conv, true);
33540 }
33541
33542 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) {
33543         LDKChannelManager this_arg_conv;
33544         this_arg_conv.inner = untag_ptr(this_arg);
33545         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33547         this_arg_conv.is_owned = false;
33548         LDKThirtyTwoBytes intercept_id_ref;
33549         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
33550         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
33551         uint8_t next_hop_channel_id_arr[32];
33552         CHECK((*env)->GetArrayLength(env, next_hop_channel_id) == 32);
33553         (*env)->GetByteArrayRegion(env, next_hop_channel_id, 0, 32, next_hop_channel_id_arr);
33554         uint8_t (*next_hop_channel_id_ref)[32] = &next_hop_channel_id_arr;
33555         LDKPublicKey next_node_id_ref;
33556         CHECK((*env)->GetArrayLength(env, next_node_id) == 33);
33557         (*env)->GetByteArrayRegion(env, next_node_id, 0, 33, next_node_id_ref.compressed_form);
33558         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33559         *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);
33560         return tag_ptr(ret_conv, true);
33561 }
33562
33563 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) {
33564         LDKChannelManager this_arg_conv;
33565         this_arg_conv.inner = untag_ptr(this_arg);
33566         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33568         this_arg_conv.is_owned = false;
33569         LDKThirtyTwoBytes intercept_id_ref;
33570         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
33571         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
33572         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33573         *ret_conv = ChannelManager_fail_intercepted_htlc(&this_arg_conv, intercept_id_ref);
33574         return tag_ptr(ret_conv, true);
33575 }
33576
33577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
33578         LDKChannelManager this_arg_conv;
33579         this_arg_conv.inner = untag_ptr(this_arg);
33580         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33582         this_arg_conv.is_owned = false;
33583         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
33584 }
33585
33586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
33587         LDKChannelManager this_arg_conv;
33588         this_arg_conv.inner = untag_ptr(this_arg);
33589         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33591         this_arg_conv.is_owned = false;
33592         ChannelManager_timer_tick_occurred(&this_arg_conv);
33593 }
33594
33595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
33596         LDKChannelManager this_arg_conv;
33597         this_arg_conv.inner = untag_ptr(this_arg);
33598         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33600         this_arg_conv.is_owned = false;
33601         uint8_t payment_hash_arr[32];
33602         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33603         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
33604         uint8_t (*payment_hash_ref)[32] = &payment_hash_arr;
33605         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
33606 }
33607
33608 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) {
33609         LDKChannelManager this_arg_conv;
33610         this_arg_conv.inner = untag_ptr(this_arg);
33611         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33613         this_arg_conv.is_owned = false;
33614         uint8_t payment_hash_arr[32];
33615         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33616         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
33617         uint8_t (*payment_hash_ref)[32] = &payment_hash_arr;
33618         LDKFailureCode failure_code_conv = LDKFailureCode_from_java(env, failure_code);
33619         ChannelManager_fail_htlc_backwards_with_reason(&this_arg_conv, payment_hash_ref, failure_code_conv);
33620 }
33621
33622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
33623         LDKChannelManager this_arg_conv;
33624         this_arg_conv.inner = untag_ptr(this_arg);
33625         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33627         this_arg_conv.is_owned = false;
33628         LDKThirtyTwoBytes payment_preimage_ref;
33629         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33630         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33631         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
33632 }
33633
33634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
33635         LDKChannelManager this_arg_conv;
33636         this_arg_conv.inner = untag_ptr(this_arg);
33637         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33639         this_arg_conv.is_owned = false;
33640         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33641         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
33642         return ret_arr;
33643 }
33644
33645 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) {
33646         LDKChannelManager this_arg_conv;
33647         this_arg_conv.inner = untag_ptr(this_arg);
33648         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33650         this_arg_conv.is_owned = false;
33651         uint8_t temporary_channel_id_arr[32];
33652         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33653         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33654         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33655         LDKPublicKey counterparty_node_id_ref;
33656         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33657         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33658         LDKU128 user_channel_id_ref;
33659         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33660         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33661         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33662         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id_ref);
33663         return tag_ptr(ret_conv, true);
33664 }
33665
33666 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) {
33667         LDKChannelManager this_arg_conv;
33668         this_arg_conv.inner = untag_ptr(this_arg);
33669         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33671         this_arg_conv.is_owned = false;
33672         uint8_t temporary_channel_id_arr[32];
33673         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33674         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33675         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33676         LDKPublicKey counterparty_node_id_ref;
33677         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33678         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33679         LDKU128 user_channel_id_ref;
33680         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33681         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33682         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33683         *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);
33684         return tag_ptr(ret_conv, true);
33685 }
33686
33687 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) {
33688         LDKChannelManager this_arg_conv;
33689         this_arg_conv.inner = untag_ptr(this_arg);
33690         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33692         this_arg_conv.is_owned = false;
33693         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33694         CHECK_ACCESS(min_value_msat_ptr);
33695         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33696         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33697         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
33698         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
33699         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
33700         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
33701         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
33702         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, min_final_cltv_expiry_delta_conv);
33703         return tag_ptr(ret_conv, true);
33704 }
33705
33706 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) {
33707         LDKChannelManager this_arg_conv;
33708         this_arg_conv.inner = untag_ptr(this_arg);
33709         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33711         this_arg_conv.is_owned = false;
33712         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33713         CHECK_ACCESS(min_value_msat_ptr);
33714         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33715         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33716         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
33717         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
33718         return tag_ptr(ret_conv, true);
33719 }
33720
33721 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) {
33722         LDKChannelManager this_arg_conv;
33723         this_arg_conv.inner = untag_ptr(this_arg);
33724         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33726         this_arg_conv.is_owned = false;
33727         LDKThirtyTwoBytes payment_hash_ref;
33728         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33729         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33730         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33731         CHECK_ACCESS(min_value_msat_ptr);
33732         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33733         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33734         void* min_final_cltv_expiry_ptr = untag_ptr(min_final_cltv_expiry);
33735         CHECK_ACCESS(min_final_cltv_expiry_ptr);
33736         LDKCOption_u16Z min_final_cltv_expiry_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_ptr);
33737         min_final_cltv_expiry_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry));
33738         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
33739         *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);
33740         return tag_ptr(ret_conv, true);
33741 }
33742
33743 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) {
33744         LDKChannelManager this_arg_conv;
33745         this_arg_conv.inner = untag_ptr(this_arg);
33746         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33748         this_arg_conv.is_owned = false;
33749         LDKThirtyTwoBytes payment_hash_ref;
33750         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33751         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33752         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33753         CHECK_ACCESS(min_value_msat_ptr);
33754         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33755         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33756         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
33757         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
33758         return tag_ptr(ret_conv, true);
33759 }
33760
33761 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) {
33762         LDKChannelManager this_arg_conv;
33763         this_arg_conv.inner = untag_ptr(this_arg);
33764         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33766         this_arg_conv.is_owned = false;
33767         LDKThirtyTwoBytes payment_hash_ref;
33768         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33769         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33770         LDKThirtyTwoBytes payment_secret_ref;
33771         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
33772         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
33773         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
33774         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
33775         return tag_ptr(ret_conv, true);
33776 }
33777
33778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
33779         LDKChannelManager this_arg_conv;
33780         this_arg_conv.inner = untag_ptr(this_arg);
33781         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33783         this_arg_conv.is_owned = false;
33784         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
33785         return ret_conv;
33786 }
33787
33788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
33789         LDKChannelManager this_arg_conv;
33790         this_arg_conv.inner = untag_ptr(this_arg);
33791         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33793         this_arg_conv.is_owned = false;
33794         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
33795         int64_t ret_ref = 0;
33796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33798         return ret_ref;
33799 }
33800
33801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1intercept_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
33802         LDKChannelManager this_arg_conv;
33803         this_arg_conv.inner = untag_ptr(this_arg);
33804         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33806         this_arg_conv.is_owned = false;
33807         int64_t ret_conv = ChannelManager_get_intercept_scid(&this_arg_conv);
33808         return ret_conv;
33809 }
33810
33811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1compute_1inflight_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg) {
33812         LDKChannelManager this_arg_conv;
33813         this_arg_conv.inner = untag_ptr(this_arg);
33814         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33816         this_arg_conv.is_owned = false;
33817         LDKInFlightHtlcs ret_var = ChannelManager_compute_inflight_htlcs(&this_arg_conv);
33818         int64_t ret_ref = 0;
33819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33820         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33821         return ret_ref;
33822 }
33823
33824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33825         LDKChannelManager this_arg_conv;
33826         this_arg_conv.inner = untag_ptr(this_arg);
33827         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33829         this_arg_conv.is_owned = false;
33830         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
33831         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
33832         return tag_ptr(ret_ret, true);
33833 }
33834
33835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33836         LDKChannelManager this_arg_conv;
33837         this_arg_conv.inner = untag_ptr(this_arg);
33838         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33840         this_arg_conv.is_owned = false;
33841         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
33842         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
33843         return tag_ptr(ret_ret, true);
33844 }
33845
33846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
33847         LDKChannelManager this_arg_conv;
33848         this_arg_conv.inner = untag_ptr(this_arg);
33849         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33851         this_arg_conv.is_owned = false;
33852         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
33853         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
33854         return tag_ptr(ret_ret, true);
33855 }
33856
33857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
33858         LDKChannelManager this_arg_conv;
33859         this_arg_conv.inner = untag_ptr(this_arg);
33860         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33862         this_arg_conv.is_owned = false;
33863         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
33864         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
33865         return tag_ptr(ret_ret, true);
33866 }
33867
33868 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) {
33869         LDKChannelManager this_arg_conv;
33870         this_arg_conv.inner = untag_ptr(this_arg);
33871         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33873         this_arg_conv.is_owned = false;
33874         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
33875         return ret_conv;
33876 }
33877
33878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
33879         LDKChannelManager this_arg_conv;
33880         this_arg_conv.inner = untag_ptr(this_arg);
33881         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33883         this_arg_conv.is_owned = false;
33884         ChannelManager_await_persistable_update(&this_arg_conv);
33885 }
33886
33887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1persistable_1update_1future(JNIEnv *env, jclass clz, int64_t this_arg) {
33888         LDKChannelManager this_arg_conv;
33889         this_arg_conv.inner = untag_ptr(this_arg);
33890         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33892         this_arg_conv.is_owned = false;
33893         LDKFuture ret_var = ChannelManager_get_persistable_update_future(&this_arg_conv);
33894         int64_t ret_ref = 0;
33895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33896         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33897         return ret_ref;
33898 }
33899
33900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
33901         LDKChannelManager this_arg_conv;
33902         this_arg_conv.inner = untag_ptr(this_arg);
33903         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33905         this_arg_conv.is_owned = false;
33906         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
33907         int64_t ret_ref = 0;
33908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33910         return ret_ref;
33911 }
33912
33913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1node_1features(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         LDKNodeFeatures ret_var = ChannelManager_node_features(&this_arg_conv);
33920         int64_t ret_ref = 0;
33921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33922         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33923         return ret_ref;
33924 }
33925
33926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
33927         LDKChannelManager this_arg_conv;
33928         this_arg_conv.inner = untag_ptr(this_arg);
33929         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33931         this_arg_conv.is_owned = false;
33932         LDKChannelFeatures ret_var = ChannelManager_channel_features(&this_arg_conv);
33933         int64_t ret_ref = 0;
33934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33935         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33936         return ret_ref;
33937 }
33938
33939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1type_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
33940         LDKChannelManager this_arg_conv;
33941         this_arg_conv.inner = untag_ptr(this_arg);
33942         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33944         this_arg_conv.is_owned = false;
33945         LDKChannelTypeFeatures ret_var = ChannelManager_channel_type_features(&this_arg_conv);
33946         int64_t ret_ref = 0;
33947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33948         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33949         return ret_ref;
33950 }
33951
33952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1init_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
33953         LDKChannelManager this_arg_conv;
33954         this_arg_conv.inner = untag_ptr(this_arg);
33955         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33957         this_arg_conv.is_owned = false;
33958         LDKInitFeatures ret_var = ChannelManager_init_features(&this_arg_conv);
33959         int64_t ret_ref = 0;
33960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33961         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33962         return ret_ref;
33963 }
33964
33965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
33966         LDKChannelManager this_arg_conv;
33967         this_arg_conv.inner = untag_ptr(this_arg);
33968         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33970         this_arg_conv.is_owned = false;
33971         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
33972         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
33973         return tag_ptr(ret_ret, true);
33974 }
33975
33976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1init_1features(JNIEnv *env, jclass clz, int64_t _config) {
33977         LDKUserConfig _config_conv;
33978         _config_conv.inner = untag_ptr(_config);
33979         _config_conv.is_owned = ptr_is_owned(_config);
33980         CHECK_INNER_FIELD_ACCESS_OR_NULL(_config_conv);
33981         _config_conv.is_owned = false;
33982         LDKInitFeatures ret_var = provided_init_features(&_config_conv);
33983         int64_t ret_ref = 0;
33984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33985         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33986         return ret_ref;
33987 }
33988
33989 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
33990         LDKCounterpartyForwardingInfo obj_conv;
33991         obj_conv.inner = untag_ptr(obj);
33992         obj_conv.is_owned = ptr_is_owned(obj);
33993         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33994         obj_conv.is_owned = false;
33995         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
33996         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33997         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33998         CVec_u8Z_free(ret_var);
33999         return ret_arr;
34000 }
34001
34002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34003         LDKu8slice ser_ref;
34004         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34005         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34006         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
34007         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
34008         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34009         return tag_ptr(ret_conv, true);
34010 }
34011
34012 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
34013         LDKChannelCounterparty obj_conv;
34014         obj_conv.inner = untag_ptr(obj);
34015         obj_conv.is_owned = ptr_is_owned(obj);
34016         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34017         obj_conv.is_owned = false;
34018         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
34019         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34020         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34021         CVec_u8Z_free(ret_var);
34022         return ret_arr;
34023 }
34024
34025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34026         LDKu8slice ser_ref;
34027         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34028         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34029         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
34030         *ret_conv = ChannelCounterparty_read(ser_ref);
34031         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34032         return tag_ptr(ret_conv, true);
34033 }
34034
34035 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
34036         LDKChannelDetails obj_conv;
34037         obj_conv.inner = untag_ptr(obj);
34038         obj_conv.is_owned = ptr_is_owned(obj);
34039         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34040         obj_conv.is_owned = false;
34041         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
34042         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34043         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34044         CVec_u8Z_free(ret_var);
34045         return ret_arr;
34046 }
34047
34048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34049         LDKu8slice ser_ref;
34050         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34051         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34052         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
34053         *ret_conv = ChannelDetails_read(ser_ref);
34054         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34055         return tag_ptr(ret_conv, true);
34056 }
34057
34058 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
34059         LDKPhantomRouteHints obj_conv;
34060         obj_conv.inner = untag_ptr(obj);
34061         obj_conv.is_owned = ptr_is_owned(obj);
34062         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34063         obj_conv.is_owned = false;
34064         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
34065         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34066         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34067         CVec_u8Z_free(ret_var);
34068         return ret_arr;
34069 }
34070
34071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34072         LDKu8slice ser_ref;
34073         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34074         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34075         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
34076         *ret_conv = PhantomRouteHints_read(ser_ref);
34077         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34078         return tag_ptr(ret_conv, true);
34079 }
34080
34081 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
34082         LDKChannelManager obj_conv;
34083         obj_conv.inner = untag_ptr(obj);
34084         obj_conv.is_owned = ptr_is_owned(obj);
34085         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34086         obj_conv.is_owned = false;
34087         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
34088         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34089         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34090         CVec_u8Z_free(ret_var);
34091         return ret_arr;
34092 }
34093
34094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34095         LDKChannelManagerReadArgs this_obj_conv;
34096         this_obj_conv.inner = untag_ptr(this_obj);
34097         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34099         ChannelManagerReadArgs_free(this_obj_conv);
34100 }
34101
34102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1entropy_1source(JNIEnv *env, jclass clz, int64_t this_ptr) {
34103         LDKChannelManagerReadArgs this_ptr_conv;
34104         this_ptr_conv.inner = untag_ptr(this_ptr);
34105         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34107         this_ptr_conv.is_owned = false;
34108         // WARNING: This object doesn't live past this scope, needs clone!
34109         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_entropy_source(&this_ptr_conv), false);
34110         return ret_ret;
34111 }
34112
34113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1entropy_1source(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34114         LDKChannelManagerReadArgs this_ptr_conv;
34115         this_ptr_conv.inner = untag_ptr(this_ptr);
34116         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34118         this_ptr_conv.is_owned = false;
34119         void* val_ptr = untag_ptr(val);
34120         CHECK_ACCESS(val_ptr);
34121         LDKEntropySource val_conv = *(LDKEntropySource*)(val_ptr);
34122         if (val_conv.free == LDKEntropySource_JCalls_free) {
34123                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34124                 LDKEntropySource_JCalls_cloned(&val_conv);
34125         }
34126         ChannelManagerReadArgs_set_entropy_source(&this_ptr_conv, val_conv);
34127 }
34128
34129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1node_1signer(JNIEnv *env, jclass clz, int64_t this_ptr) {
34130         LDKChannelManagerReadArgs this_ptr_conv;
34131         this_ptr_conv.inner = untag_ptr(this_ptr);
34132         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34134         this_ptr_conv.is_owned = false;
34135         // WARNING: This object doesn't live past this scope, needs clone!
34136         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_node_signer(&this_ptr_conv), false);
34137         return ret_ret;
34138 }
34139
34140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1node_1signer(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34141         LDKChannelManagerReadArgs this_ptr_conv;
34142         this_ptr_conv.inner = untag_ptr(this_ptr);
34143         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34145         this_ptr_conv.is_owned = false;
34146         void* val_ptr = untag_ptr(val);
34147         CHECK_ACCESS(val_ptr);
34148         LDKNodeSigner val_conv = *(LDKNodeSigner*)(val_ptr);
34149         if (val_conv.free == LDKNodeSigner_JCalls_free) {
34150                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34151                 LDKNodeSigner_JCalls_cloned(&val_conv);
34152         }
34153         ChannelManagerReadArgs_set_node_signer(&this_ptr_conv, val_conv);
34154 }
34155
34156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1signer_1provider(JNIEnv *env, jclass clz, int64_t this_ptr) {
34157         LDKChannelManagerReadArgs this_ptr_conv;
34158         this_ptr_conv.inner = untag_ptr(this_ptr);
34159         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34161         this_ptr_conv.is_owned = false;
34162         // WARNING: This object doesn't live past this scope, needs clone!
34163         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_signer_provider(&this_ptr_conv), false);
34164         return ret_ret;
34165 }
34166
34167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1signer_1provider(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34168         LDKChannelManagerReadArgs this_ptr_conv;
34169         this_ptr_conv.inner = untag_ptr(this_ptr);
34170         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34172         this_ptr_conv.is_owned = false;
34173         void* val_ptr = untag_ptr(val);
34174         CHECK_ACCESS(val_ptr);
34175         LDKSignerProvider val_conv = *(LDKSignerProvider*)(val_ptr);
34176         if (val_conv.free == LDKSignerProvider_JCalls_free) {
34177                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34178                 LDKSignerProvider_JCalls_cloned(&val_conv);
34179         }
34180         ChannelManagerReadArgs_set_signer_provider(&this_ptr_conv, val_conv);
34181 }
34182
34183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
34184         LDKChannelManagerReadArgs this_ptr_conv;
34185         this_ptr_conv.inner = untag_ptr(this_ptr);
34186         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34188         this_ptr_conv.is_owned = false;
34189         // WARNING: This object doesn't live past this scope, needs clone!
34190         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv), false);
34191         return ret_ret;
34192 }
34193
34194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34195         LDKChannelManagerReadArgs this_ptr_conv;
34196         this_ptr_conv.inner = untag_ptr(this_ptr);
34197         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34199         this_ptr_conv.is_owned = false;
34200         void* val_ptr = untag_ptr(val);
34201         CHECK_ACCESS(val_ptr);
34202         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
34203         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
34204                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34205                 LDKFeeEstimator_JCalls_cloned(&val_conv);
34206         }
34207         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
34208 }
34209
34210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
34211         LDKChannelManagerReadArgs this_ptr_conv;
34212         this_ptr_conv.inner = untag_ptr(this_ptr);
34213         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34215         this_ptr_conv.is_owned = false;
34216         // WARNING: This object doesn't live past this scope, needs clone!
34217         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv), false);
34218         return ret_ret;
34219 }
34220
34221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34222         LDKChannelManagerReadArgs this_ptr_conv;
34223         this_ptr_conv.inner = untag_ptr(this_ptr);
34224         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34226         this_ptr_conv.is_owned = false;
34227         void* val_ptr = untag_ptr(val);
34228         CHECK_ACCESS(val_ptr);
34229         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
34230         if (val_conv.free == LDKWatch_JCalls_free) {
34231                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34232                 LDKWatch_JCalls_cloned(&val_conv);
34233         }
34234         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
34235 }
34236
34237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
34238         LDKChannelManagerReadArgs this_ptr_conv;
34239         this_ptr_conv.inner = untag_ptr(this_ptr);
34240         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34242         this_ptr_conv.is_owned = false;
34243         // WARNING: This object doesn't live past this scope, needs clone!
34244         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv), false);
34245         return ret_ret;
34246 }
34247
34248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34249         LDKChannelManagerReadArgs this_ptr_conv;
34250         this_ptr_conv.inner = untag_ptr(this_ptr);
34251         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34253         this_ptr_conv.is_owned = false;
34254         void* val_ptr = untag_ptr(val);
34255         CHECK_ACCESS(val_ptr);
34256         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
34257         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
34258                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34259                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
34260         }
34261         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
34262 }
34263
34264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1router(JNIEnv *env, jclass clz, int64_t this_ptr) {
34265         LDKChannelManagerReadArgs this_ptr_conv;
34266         this_ptr_conv.inner = untag_ptr(this_ptr);
34267         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34269         this_ptr_conv.is_owned = false;
34270         // WARNING: This object doesn't live past this scope, needs clone!
34271         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_router(&this_ptr_conv), false);
34272         return ret_ret;
34273 }
34274
34275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1router(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34276         LDKChannelManagerReadArgs this_ptr_conv;
34277         this_ptr_conv.inner = untag_ptr(this_ptr);
34278         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34280         this_ptr_conv.is_owned = false;
34281         void* val_ptr = untag_ptr(val);
34282         CHECK_ACCESS(val_ptr);
34283         LDKRouter val_conv = *(LDKRouter*)(val_ptr);
34284         if (val_conv.free == LDKRouter_JCalls_free) {
34285                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34286                 LDKRouter_JCalls_cloned(&val_conv);
34287         }
34288         ChannelManagerReadArgs_set_router(&this_ptr_conv, val_conv);
34289 }
34290
34291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
34292         LDKChannelManagerReadArgs this_ptr_conv;
34293         this_ptr_conv.inner = untag_ptr(this_ptr);
34294         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34296         this_ptr_conv.is_owned = false;
34297         // WARNING: This object doesn't live past this scope, needs clone!
34298         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_logger(&this_ptr_conv), false);
34299         return ret_ret;
34300 }
34301
34302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34303         LDKChannelManagerReadArgs this_ptr_conv;
34304         this_ptr_conv.inner = untag_ptr(this_ptr);
34305         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34307         this_ptr_conv.is_owned = false;
34308         void* val_ptr = untag_ptr(val);
34309         CHECK_ACCESS(val_ptr);
34310         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
34311         if (val_conv.free == LDKLogger_JCalls_free) {
34312                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34313                 LDKLogger_JCalls_cloned(&val_conv);
34314         }
34315         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
34316 }
34317
34318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
34319         LDKChannelManagerReadArgs this_ptr_conv;
34320         this_ptr_conv.inner = untag_ptr(this_ptr);
34321         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34323         this_ptr_conv.is_owned = false;
34324         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
34325         int64_t ret_ref = 0;
34326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34327         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34328         return ret_ref;
34329 }
34330
34331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34332         LDKChannelManagerReadArgs this_ptr_conv;
34333         this_ptr_conv.inner = untag_ptr(this_ptr);
34334         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34336         this_ptr_conv.is_owned = false;
34337         LDKUserConfig val_conv;
34338         val_conv.inner = untag_ptr(val);
34339         val_conv.is_owned = ptr_is_owned(val);
34340         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34341         val_conv = UserConfig_clone(&val_conv);
34342         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
34343 }
34344
34345 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) {
34346         void* entropy_source_ptr = untag_ptr(entropy_source);
34347         CHECK_ACCESS(entropy_source_ptr);
34348         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
34349         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
34350                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34351                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
34352         }
34353         void* node_signer_ptr = untag_ptr(node_signer);
34354         CHECK_ACCESS(node_signer_ptr);
34355         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
34356         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
34357                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34358                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
34359         }
34360         void* signer_provider_ptr = untag_ptr(signer_provider);
34361         CHECK_ACCESS(signer_provider_ptr);
34362         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
34363         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
34364                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34365                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
34366         }
34367         void* fee_estimator_ptr = untag_ptr(fee_estimator);
34368         CHECK_ACCESS(fee_estimator_ptr);
34369         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
34370         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
34371                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34372                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
34373         }
34374         void* chain_monitor_ptr = untag_ptr(chain_monitor);
34375         CHECK_ACCESS(chain_monitor_ptr);
34376         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
34377         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
34378                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34379                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
34380         }
34381         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
34382         CHECK_ACCESS(tx_broadcaster_ptr);
34383         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
34384         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
34385                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34386                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
34387         }
34388         void* router_ptr = untag_ptr(router);
34389         CHECK_ACCESS(router_ptr);
34390         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
34391         if (router_conv.free == LDKRouter_JCalls_free) {
34392                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34393                 LDKRouter_JCalls_cloned(&router_conv);
34394         }
34395         void* logger_ptr = untag_ptr(logger);
34396         CHECK_ACCESS(logger_ptr);
34397         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34398         if (logger_conv.free == LDKLogger_JCalls_free) {
34399                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34400                 LDKLogger_JCalls_cloned(&logger_conv);
34401         }
34402         LDKUserConfig default_config_conv;
34403         default_config_conv.inner = untag_ptr(default_config);
34404         default_config_conv.is_owned = ptr_is_owned(default_config);
34405         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
34406         default_config_conv = UserConfig_clone(&default_config_conv);
34407         LDKCVec_ChannelMonitorZ channel_monitors_constr;
34408         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
34409         if (channel_monitors_constr.datalen > 0)
34410                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
34411         else
34412                 channel_monitors_constr.data = NULL;
34413         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
34414         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
34415                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
34416                 LDKChannelMonitor channel_monitors_conv_16_conv;
34417                 channel_monitors_conv_16_conv.inner = untag_ptr(channel_monitors_conv_16);
34418                 channel_monitors_conv_16_conv.is_owned = ptr_is_owned(channel_monitors_conv_16);
34419                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
34420                 channel_monitors_conv_16_conv.is_owned = false;
34421                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
34422         }
34423         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
34424         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);
34425         int64_t ret_ref = 0;
34426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34427         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34428         return ret_ref;
34429 }
34430
34431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
34432         LDKu8slice ser_ref;
34433         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34434         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34435         LDKChannelManagerReadArgs arg_conv;
34436         arg_conv.inner = untag_ptr(arg);
34437         arg_conv.is_owned = ptr_is_owned(arg);
34438         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34439         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
34440         
34441         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
34442         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
34443         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34444         return tag_ptr(ret_conv, true);
34445 }
34446
34447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34448         LDKExpandedKey this_obj_conv;
34449         this_obj_conv.inner = untag_ptr(this_obj);
34450         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34452         ExpandedKey_free(this_obj_conv);
34453 }
34454
34455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
34456         uint8_t key_material_arr[32];
34457         CHECK((*env)->GetArrayLength(env, key_material) == 32);
34458         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
34459         uint8_t (*key_material_ref)[32] = &key_material_arr;
34460         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
34461         int64_t ret_ref = 0;
34462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34463         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34464         return ret_ref;
34465 }
34466
34467 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) {
34468         LDKExpandedKey keys_conv;
34469         keys_conv.inner = untag_ptr(keys);
34470         keys_conv.is_owned = ptr_is_owned(keys);
34471         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
34472         keys_conv.is_owned = false;
34473         void* min_value_msat_ptr = untag_ptr(min_value_msat);
34474         CHECK_ACCESS(min_value_msat_ptr);
34475         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
34476         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
34477         void* entropy_source_ptr = untag_ptr(entropy_source);
34478         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
34479         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
34480         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
34481         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
34482         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
34483         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
34484         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
34485         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, entropy_source_conv, current_time, min_final_cltv_expiry_delta_conv);
34486         return tag_ptr(ret_conv, true);
34487 }
34488
34489 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) {
34490         LDKExpandedKey keys_conv;
34491         keys_conv.inner = untag_ptr(keys);
34492         keys_conv.is_owned = ptr_is_owned(keys);
34493         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
34494         keys_conv.is_owned = false;
34495         void* min_value_msat_ptr = untag_ptr(min_value_msat);
34496         CHECK_ACCESS(min_value_msat_ptr);
34497         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
34498         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
34499         LDKThirtyTwoBytes payment_hash_ref;
34500         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
34501         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
34502         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
34503         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
34504         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
34505         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
34506         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
34507         *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);
34508         return tag_ptr(ret_conv, true);
34509 }
34510
34511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34512         if (!ptr_is_owned(this_ptr)) return;
34513         void* this_ptr_ptr = untag_ptr(this_ptr);
34514         CHECK_ACCESS(this_ptr_ptr);
34515         LDKDecodeError this_ptr_conv = *(LDKDecodeError*)(this_ptr_ptr);
34516         FREE(untag_ptr(this_ptr));
34517         DecodeError_free(this_ptr_conv);
34518 }
34519
34520 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
34521         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34522         *ret_copy = DecodeError_clone(arg);
34523         int64_t ret_ref = tag_ptr(ret_copy, true);
34524         return ret_ref;
34525 }
34526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34527         LDKDecodeError* arg_conv = (LDKDecodeError*)untag_ptr(arg);
34528         int64_t ret_conv = DecodeError_clone_ptr(arg_conv);
34529         return ret_conv;
34530 }
34531
34532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34533         LDKDecodeError* orig_conv = (LDKDecodeError*)untag_ptr(orig);
34534         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34535         *ret_copy = DecodeError_clone(orig_conv);
34536         int64_t ret_ref = tag_ptr(ret_copy, true);
34537         return ret_ref;
34538 }
34539
34540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1version(JNIEnv *env, jclass clz) {
34541         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34542         *ret_copy = DecodeError_unknown_version();
34543         int64_t ret_ref = tag_ptr(ret_copy, true);
34544         return ret_ref;
34545 }
34546
34547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1required_1feature(JNIEnv *env, jclass clz) {
34548         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34549         *ret_copy = DecodeError_unknown_required_feature();
34550         int64_t ret_ref = tag_ptr(ret_copy, true);
34551         return ret_ref;
34552 }
34553
34554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1invalid_1value(JNIEnv *env, jclass clz) {
34555         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34556         *ret_copy = DecodeError_invalid_value();
34557         int64_t ret_ref = tag_ptr(ret_copy, true);
34558         return ret_ref;
34559 }
34560
34561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1short_1read(JNIEnv *env, jclass clz) {
34562         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34563         *ret_copy = DecodeError_short_read();
34564         int64_t ret_ref = tag_ptr(ret_copy, true);
34565         return ret_ref;
34566 }
34567
34568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1bad_1length_1descriptor(JNIEnv *env, jclass clz) {
34569         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34570         *ret_copy = DecodeError_bad_length_descriptor();
34571         int64_t ret_ref = tag_ptr(ret_copy, true);
34572         return ret_ref;
34573 }
34574
34575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1io(JNIEnv *env, jclass clz, jclass a) {
34576         LDKIOError a_conv = LDKIOError_from_java(env, a);
34577         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34578         *ret_copy = DecodeError_io(a_conv);
34579         int64_t ret_ref = tag_ptr(ret_copy, true);
34580         return ret_ref;
34581 }
34582
34583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unsupported_1compression(JNIEnv *env, jclass clz) {
34584         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34585         *ret_copy = DecodeError_unsupported_compression();
34586         int64_t ret_ref = tag_ptr(ret_copy, true);
34587         return ret_ref;
34588 }
34589
34590 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DecodeError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34591         LDKDecodeError* a_conv = (LDKDecodeError*)untag_ptr(a);
34592         LDKDecodeError* b_conv = (LDKDecodeError*)untag_ptr(b);
34593         jboolean ret_conv = DecodeError_eq(a_conv, b_conv);
34594         return ret_conv;
34595 }
34596
34597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34598         LDKInit this_obj_conv;
34599         this_obj_conv.inner = untag_ptr(this_obj);
34600         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34602         Init_free(this_obj_conv);
34603 }
34604
34605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
34606         LDKInit this_ptr_conv;
34607         this_ptr_conv.inner = untag_ptr(this_ptr);
34608         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34610         this_ptr_conv.is_owned = false;
34611         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
34612         int64_t ret_ref = 0;
34613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34614         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34615         return ret_ref;
34616 }
34617
34618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34619         LDKInit this_ptr_conv;
34620         this_ptr_conv.inner = untag_ptr(this_ptr);
34621         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34623         this_ptr_conv.is_owned = false;
34624         LDKInitFeatures val_conv;
34625         val_conv.inner = untag_ptr(val);
34626         val_conv.is_owned = ptr_is_owned(val);
34627         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34628         val_conv = InitFeatures_clone(&val_conv);
34629         Init_set_features(&this_ptr_conv, val_conv);
34630 }
34631
34632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
34633         LDKInit this_ptr_conv;
34634         this_ptr_conv.inner = untag_ptr(this_ptr);
34635         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34637         this_ptr_conv.is_owned = false;
34638         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
34639         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
34640         int64_t ret_ref = tag_ptr(ret_copy, true);
34641         return ret_ref;
34642 }
34643
34644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34645         LDKInit this_ptr_conv;
34646         this_ptr_conv.inner = untag_ptr(this_ptr);
34647         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34649         this_ptr_conv.is_owned = false;
34650         void* val_ptr = untag_ptr(val);
34651         CHECK_ACCESS(val_ptr);
34652         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
34653         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(val));
34654         Init_set_remote_network_address(&this_ptr_conv, val_conv);
34655 }
34656
34657 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) {
34658         LDKInitFeatures features_arg_conv;
34659         features_arg_conv.inner = untag_ptr(features_arg);
34660         features_arg_conv.is_owned = ptr_is_owned(features_arg);
34661         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
34662         features_arg_conv = InitFeatures_clone(&features_arg_conv);
34663         void* remote_network_address_arg_ptr = untag_ptr(remote_network_address_arg);
34664         CHECK_ACCESS(remote_network_address_arg_ptr);
34665         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
34666         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
34667         int64_t ret_ref = 0;
34668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34669         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34670         return ret_ref;
34671 }
34672
34673 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
34674         LDKInit ret_var = Init_clone(arg);
34675         int64_t ret_ref = 0;
34676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34677         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34678         return ret_ref;
34679 }
34680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34681         LDKInit arg_conv;
34682         arg_conv.inner = untag_ptr(arg);
34683         arg_conv.is_owned = ptr_is_owned(arg);
34684         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34685         arg_conv.is_owned = false;
34686         int64_t ret_conv = Init_clone_ptr(&arg_conv);
34687         return ret_conv;
34688 }
34689
34690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34691         LDKInit orig_conv;
34692         orig_conv.inner = untag_ptr(orig);
34693         orig_conv.is_owned = ptr_is_owned(orig);
34694         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34695         orig_conv.is_owned = false;
34696         LDKInit ret_var = Init_clone(&orig_conv);
34697         int64_t ret_ref = 0;
34698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34699         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34700         return ret_ref;
34701 }
34702
34703 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Init_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34704         LDKInit a_conv;
34705         a_conv.inner = untag_ptr(a);
34706         a_conv.is_owned = ptr_is_owned(a);
34707         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34708         a_conv.is_owned = false;
34709         LDKInit b_conv;
34710         b_conv.inner = untag_ptr(b);
34711         b_conv.is_owned = ptr_is_owned(b);
34712         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34713         b_conv.is_owned = false;
34714         jboolean ret_conv = Init_eq(&a_conv, &b_conv);
34715         return ret_conv;
34716 }
34717
34718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34719         LDKErrorMessage this_obj_conv;
34720         this_obj_conv.inner = untag_ptr(this_obj);
34721         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34723         ErrorMessage_free(this_obj_conv);
34724 }
34725
34726 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34727         LDKErrorMessage this_ptr_conv;
34728         this_ptr_conv.inner = untag_ptr(this_ptr);
34729         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34731         this_ptr_conv.is_owned = false;
34732         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34733         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
34734         return ret_arr;
34735 }
34736
34737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34738         LDKErrorMessage this_ptr_conv;
34739         this_ptr_conv.inner = untag_ptr(this_ptr);
34740         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34742         this_ptr_conv.is_owned = false;
34743         LDKThirtyTwoBytes val_ref;
34744         CHECK((*env)->GetArrayLength(env, val) == 32);
34745         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34746         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
34747 }
34748
34749 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
34750         LDKErrorMessage this_ptr_conv;
34751         this_ptr_conv.inner = untag_ptr(this_ptr);
34752         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34754         this_ptr_conv.is_owned = false;
34755         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
34756         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34757         Str_free(ret_str);
34758         return ret_conv;
34759 }
34760
34761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34762         LDKErrorMessage this_ptr_conv;
34763         this_ptr_conv.inner = untag_ptr(this_ptr);
34764         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34766         this_ptr_conv.is_owned = false;
34767         LDKStr val_conv = java_to_owned_str(env, val);
34768         ErrorMessage_set_data(&this_ptr_conv, val_conv);
34769 }
34770
34771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
34772         LDKThirtyTwoBytes channel_id_arg_ref;
34773         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34774         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34775         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
34776         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
34777         int64_t ret_ref = 0;
34778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34779         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34780         return ret_ref;
34781 }
34782
34783 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
34784         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
34785         int64_t ret_ref = 0;
34786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34787         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34788         return ret_ref;
34789 }
34790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34791         LDKErrorMessage arg_conv;
34792         arg_conv.inner = untag_ptr(arg);
34793         arg_conv.is_owned = ptr_is_owned(arg);
34794         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34795         arg_conv.is_owned = false;
34796         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
34797         return ret_conv;
34798 }
34799
34800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34801         LDKErrorMessage orig_conv;
34802         orig_conv.inner = untag_ptr(orig);
34803         orig_conv.is_owned = ptr_is_owned(orig);
34804         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34805         orig_conv.is_owned = false;
34806         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
34807         int64_t ret_ref = 0;
34808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34809         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34810         return ret_ref;
34811 }
34812
34813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34814         LDKErrorMessage a_conv;
34815         a_conv.inner = untag_ptr(a);
34816         a_conv.is_owned = ptr_is_owned(a);
34817         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34818         a_conv.is_owned = false;
34819         LDKErrorMessage b_conv;
34820         b_conv.inner = untag_ptr(b);
34821         b_conv.is_owned = ptr_is_owned(b);
34822         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34823         b_conv.is_owned = false;
34824         jboolean ret_conv = ErrorMessage_eq(&a_conv, &b_conv);
34825         return ret_conv;
34826 }
34827
34828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34829         LDKWarningMessage this_obj_conv;
34830         this_obj_conv.inner = untag_ptr(this_obj);
34831         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34833         WarningMessage_free(this_obj_conv);
34834 }
34835
34836 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34837         LDKWarningMessage this_ptr_conv;
34838         this_ptr_conv.inner = untag_ptr(this_ptr);
34839         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34841         this_ptr_conv.is_owned = false;
34842         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34843         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
34844         return ret_arr;
34845 }
34846
34847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34848         LDKWarningMessage this_ptr_conv;
34849         this_ptr_conv.inner = untag_ptr(this_ptr);
34850         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34852         this_ptr_conv.is_owned = false;
34853         LDKThirtyTwoBytes val_ref;
34854         CHECK((*env)->GetArrayLength(env, val) == 32);
34855         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34856         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
34857 }
34858
34859 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
34860         LDKWarningMessage this_ptr_conv;
34861         this_ptr_conv.inner = untag_ptr(this_ptr);
34862         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34864         this_ptr_conv.is_owned = false;
34865         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
34866         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34867         Str_free(ret_str);
34868         return ret_conv;
34869 }
34870
34871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34872         LDKWarningMessage this_ptr_conv;
34873         this_ptr_conv.inner = untag_ptr(this_ptr);
34874         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34876         this_ptr_conv.is_owned = false;
34877         LDKStr val_conv = java_to_owned_str(env, val);
34878         WarningMessage_set_data(&this_ptr_conv, val_conv);
34879 }
34880
34881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
34882         LDKThirtyTwoBytes channel_id_arg_ref;
34883         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34884         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34885         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
34886         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
34887         int64_t ret_ref = 0;
34888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34889         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34890         return ret_ref;
34891 }
34892
34893 static inline uint64_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
34894         LDKWarningMessage ret_var = WarningMessage_clone(arg);
34895         int64_t ret_ref = 0;
34896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34897         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34898         return ret_ref;
34899 }
34900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34901         LDKWarningMessage arg_conv;
34902         arg_conv.inner = untag_ptr(arg);
34903         arg_conv.is_owned = ptr_is_owned(arg);
34904         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34905         arg_conv.is_owned = false;
34906         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
34907         return ret_conv;
34908 }
34909
34910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34911         LDKWarningMessage orig_conv;
34912         orig_conv.inner = untag_ptr(orig);
34913         orig_conv.is_owned = ptr_is_owned(orig);
34914         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34915         orig_conv.is_owned = false;
34916         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
34917         int64_t ret_ref = 0;
34918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34919         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34920         return ret_ref;
34921 }
34922
34923 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WarningMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34924         LDKWarningMessage a_conv;
34925         a_conv.inner = untag_ptr(a);
34926         a_conv.is_owned = ptr_is_owned(a);
34927         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34928         a_conv.is_owned = false;
34929         LDKWarningMessage b_conv;
34930         b_conv.inner = untag_ptr(b);
34931         b_conv.is_owned = ptr_is_owned(b);
34932         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34933         b_conv.is_owned = false;
34934         jboolean ret_conv = WarningMessage_eq(&a_conv, &b_conv);
34935         return ret_conv;
34936 }
34937
34938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34939         LDKPing this_obj_conv;
34940         this_obj_conv.inner = untag_ptr(this_obj);
34941         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34943         Ping_free(this_obj_conv);
34944 }
34945
34946 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
34947         LDKPing this_ptr_conv;
34948         this_ptr_conv.inner = untag_ptr(this_ptr);
34949         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34951         this_ptr_conv.is_owned = false;
34952         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
34953         return ret_conv;
34954 }
34955
34956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34957         LDKPing this_ptr_conv;
34958         this_ptr_conv.inner = untag_ptr(this_ptr);
34959         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34961         this_ptr_conv.is_owned = false;
34962         Ping_set_ponglen(&this_ptr_conv, val);
34963 }
34964
34965 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
34966         LDKPing this_ptr_conv;
34967         this_ptr_conv.inner = untag_ptr(this_ptr);
34968         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34970         this_ptr_conv.is_owned = false;
34971         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
34972         return ret_conv;
34973 }
34974
34975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34976         LDKPing this_ptr_conv;
34977         this_ptr_conv.inner = untag_ptr(this_ptr);
34978         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34980         this_ptr_conv.is_owned = false;
34981         Ping_set_byteslen(&this_ptr_conv, val);
34982 }
34983
34984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
34985         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
34986         int64_t ret_ref = 0;
34987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34989         return ret_ref;
34990 }
34991
34992 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
34993         LDKPing ret_var = Ping_clone(arg);
34994         int64_t ret_ref = 0;
34995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34996         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34997         return ret_ref;
34998 }
34999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35000         LDKPing arg_conv;
35001         arg_conv.inner = untag_ptr(arg);
35002         arg_conv.is_owned = ptr_is_owned(arg);
35003         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35004         arg_conv.is_owned = false;
35005         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
35006         return ret_conv;
35007 }
35008
35009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35010         LDKPing orig_conv;
35011         orig_conv.inner = untag_ptr(orig);
35012         orig_conv.is_owned = ptr_is_owned(orig);
35013         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35014         orig_conv.is_owned = false;
35015         LDKPing ret_var = Ping_clone(&orig_conv);
35016         int64_t ret_ref = 0;
35017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35019         return ret_ref;
35020 }
35021
35022 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Ping_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35023         LDKPing a_conv;
35024         a_conv.inner = untag_ptr(a);
35025         a_conv.is_owned = ptr_is_owned(a);
35026         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35027         a_conv.is_owned = false;
35028         LDKPing b_conv;
35029         b_conv.inner = untag_ptr(b);
35030         b_conv.is_owned = ptr_is_owned(b);
35031         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35032         b_conv.is_owned = false;
35033         jboolean ret_conv = Ping_eq(&a_conv, &b_conv);
35034         return ret_conv;
35035 }
35036
35037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35038         LDKPong this_obj_conv;
35039         this_obj_conv.inner = untag_ptr(this_obj);
35040         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35042         Pong_free(this_obj_conv);
35043 }
35044
35045 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
35046         LDKPong this_ptr_conv;
35047         this_ptr_conv.inner = untag_ptr(this_ptr);
35048         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35050         this_ptr_conv.is_owned = false;
35051         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
35052         return ret_conv;
35053 }
35054
35055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35056         LDKPong this_ptr_conv;
35057         this_ptr_conv.inner = untag_ptr(this_ptr);
35058         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35060         this_ptr_conv.is_owned = false;
35061         Pong_set_byteslen(&this_ptr_conv, val);
35062 }
35063
35064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
35065         LDKPong ret_var = Pong_new(byteslen_arg);
35066         int64_t ret_ref = 0;
35067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35068         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35069         return ret_ref;
35070 }
35071
35072 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
35073         LDKPong ret_var = Pong_clone(arg);
35074         int64_t ret_ref = 0;
35075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35076         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35077         return ret_ref;
35078 }
35079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35080         LDKPong arg_conv;
35081         arg_conv.inner = untag_ptr(arg);
35082         arg_conv.is_owned = ptr_is_owned(arg);
35083         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35084         arg_conv.is_owned = false;
35085         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
35086         return ret_conv;
35087 }
35088
35089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35090         LDKPong orig_conv;
35091         orig_conv.inner = untag_ptr(orig);
35092         orig_conv.is_owned = ptr_is_owned(orig);
35093         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35094         orig_conv.is_owned = false;
35095         LDKPong ret_var = Pong_clone(&orig_conv);
35096         int64_t ret_ref = 0;
35097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35098         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35099         return ret_ref;
35100 }
35101
35102 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Pong_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35103         LDKPong a_conv;
35104         a_conv.inner = untag_ptr(a);
35105         a_conv.is_owned = ptr_is_owned(a);
35106         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35107         a_conv.is_owned = false;
35108         LDKPong b_conv;
35109         b_conv.inner = untag_ptr(b);
35110         b_conv.is_owned = ptr_is_owned(b);
35111         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35112         b_conv.is_owned = false;
35113         jboolean ret_conv = Pong_eq(&a_conv, &b_conv);
35114         return ret_conv;
35115 }
35116
35117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35118         LDKOpenChannel this_obj_conv;
35119         this_obj_conv.inner = untag_ptr(this_obj);
35120         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35122         OpenChannel_free(this_obj_conv);
35123 }
35124
35125 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35126         LDKOpenChannel this_ptr_conv;
35127         this_ptr_conv.inner = untag_ptr(this_ptr);
35128         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35130         this_ptr_conv.is_owned = false;
35131         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35132         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
35133         return ret_arr;
35134 }
35135
35136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35137         LDKOpenChannel this_ptr_conv;
35138         this_ptr_conv.inner = untag_ptr(this_ptr);
35139         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35141         this_ptr_conv.is_owned = false;
35142         LDKThirtyTwoBytes val_ref;
35143         CHECK((*env)->GetArrayLength(env, val) == 32);
35144         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35145         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
35146 }
35147
35148 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35149         LDKOpenChannel this_ptr_conv;
35150         this_ptr_conv.inner = untag_ptr(this_ptr);
35151         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35153         this_ptr_conv.is_owned = false;
35154         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35155         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
35156         return ret_arr;
35157 }
35158
35159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35160         LDKOpenChannel this_ptr_conv;
35161         this_ptr_conv.inner = untag_ptr(this_ptr);
35162         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35164         this_ptr_conv.is_owned = false;
35165         LDKThirtyTwoBytes val_ref;
35166         CHECK((*env)->GetArrayLength(env, val) == 32);
35167         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35168         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
35169 }
35170
35171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35172         LDKOpenChannel this_ptr_conv;
35173         this_ptr_conv.inner = untag_ptr(this_ptr);
35174         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35176         this_ptr_conv.is_owned = false;
35177         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
35178         return ret_conv;
35179 }
35180
35181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35182         LDKOpenChannel this_ptr_conv;
35183         this_ptr_conv.inner = untag_ptr(this_ptr);
35184         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35186         this_ptr_conv.is_owned = false;
35187         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
35188 }
35189
35190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35191         LDKOpenChannel this_ptr_conv;
35192         this_ptr_conv.inner = untag_ptr(this_ptr);
35193         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35195         this_ptr_conv.is_owned = false;
35196         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
35197         return ret_conv;
35198 }
35199
35200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35201         LDKOpenChannel this_ptr_conv;
35202         this_ptr_conv.inner = untag_ptr(this_ptr);
35203         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35205         this_ptr_conv.is_owned = false;
35206         OpenChannel_set_push_msat(&this_ptr_conv, val);
35207 }
35208
35209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35210         LDKOpenChannel this_ptr_conv;
35211         this_ptr_conv.inner = untag_ptr(this_ptr);
35212         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35214         this_ptr_conv.is_owned = false;
35215         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
35216         return ret_conv;
35217 }
35218
35219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35220         LDKOpenChannel this_ptr_conv;
35221         this_ptr_conv.inner = untag_ptr(this_ptr);
35222         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35224         this_ptr_conv.is_owned = false;
35225         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
35226 }
35227
35228 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) {
35229         LDKOpenChannel this_ptr_conv;
35230         this_ptr_conv.inner = untag_ptr(this_ptr);
35231         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35233         this_ptr_conv.is_owned = false;
35234         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
35235         return ret_conv;
35236 }
35237
35238 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) {
35239         LDKOpenChannel this_ptr_conv;
35240         this_ptr_conv.inner = untag_ptr(this_ptr);
35241         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35243         this_ptr_conv.is_owned = false;
35244         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
35245 }
35246
35247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35248         LDKOpenChannel this_ptr_conv;
35249         this_ptr_conv.inner = untag_ptr(this_ptr);
35250         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35252         this_ptr_conv.is_owned = false;
35253         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
35254         return ret_conv;
35255 }
35256
35257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35258         LDKOpenChannel this_ptr_conv;
35259         this_ptr_conv.inner = untag_ptr(this_ptr);
35260         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35262         this_ptr_conv.is_owned = false;
35263         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
35264 }
35265
35266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35267         LDKOpenChannel this_ptr_conv;
35268         this_ptr_conv.inner = untag_ptr(this_ptr);
35269         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35271         this_ptr_conv.is_owned = false;
35272         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
35273         return ret_conv;
35274 }
35275
35276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35277         LDKOpenChannel this_ptr_conv;
35278         this_ptr_conv.inner = untag_ptr(this_ptr);
35279         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35281         this_ptr_conv.is_owned = false;
35282         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
35283 }
35284
35285 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
35286         LDKOpenChannel this_ptr_conv;
35287         this_ptr_conv.inner = untag_ptr(this_ptr);
35288         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35290         this_ptr_conv.is_owned = false;
35291         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
35292         return ret_conv;
35293 }
35294
35295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35296         LDKOpenChannel this_ptr_conv;
35297         this_ptr_conv.inner = untag_ptr(this_ptr);
35298         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35300         this_ptr_conv.is_owned = false;
35301         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
35302 }
35303
35304 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
35305         LDKOpenChannel this_ptr_conv;
35306         this_ptr_conv.inner = untag_ptr(this_ptr);
35307         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35309         this_ptr_conv.is_owned = false;
35310         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
35311         return ret_conv;
35312 }
35313
35314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35315         LDKOpenChannel this_ptr_conv;
35316         this_ptr_conv.inner = untag_ptr(this_ptr);
35317         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35319         this_ptr_conv.is_owned = false;
35320         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
35321 }
35322
35323 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35324         LDKOpenChannel this_ptr_conv;
35325         this_ptr_conv.inner = untag_ptr(this_ptr);
35326         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35328         this_ptr_conv.is_owned = false;
35329         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
35330         return ret_conv;
35331 }
35332
35333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35334         LDKOpenChannel this_ptr_conv;
35335         this_ptr_conv.inner = untag_ptr(this_ptr);
35336         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35338         this_ptr_conv.is_owned = false;
35339         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
35340 }
35341
35342 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
35343         LDKOpenChannel this_ptr_conv;
35344         this_ptr_conv.inner = untag_ptr(this_ptr);
35345         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35347         this_ptr_conv.is_owned = false;
35348         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35349         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
35350         return ret_arr;
35351 }
35352
35353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35354         LDKOpenChannel this_ptr_conv;
35355         this_ptr_conv.inner = untag_ptr(this_ptr);
35356         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35358         this_ptr_conv.is_owned = false;
35359         LDKPublicKey val_ref;
35360         CHECK((*env)->GetArrayLength(env, val) == 33);
35361         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35362         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
35363 }
35364
35365 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35366         LDKOpenChannel this_ptr_conv;
35367         this_ptr_conv.inner = untag_ptr(this_ptr);
35368         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35370         this_ptr_conv.is_owned = false;
35371         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35372         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
35373         return ret_arr;
35374 }
35375
35376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35377         LDKOpenChannel this_ptr_conv;
35378         this_ptr_conv.inner = untag_ptr(this_ptr);
35379         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35381         this_ptr_conv.is_owned = false;
35382         LDKPublicKey val_ref;
35383         CHECK((*env)->GetArrayLength(env, val) == 33);
35384         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35385         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
35386 }
35387
35388 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35389         LDKOpenChannel this_ptr_conv;
35390         this_ptr_conv.inner = untag_ptr(this_ptr);
35391         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35393         this_ptr_conv.is_owned = false;
35394         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35395         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
35396         return ret_arr;
35397 }
35398
35399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35400         LDKOpenChannel this_ptr_conv;
35401         this_ptr_conv.inner = untag_ptr(this_ptr);
35402         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35404         this_ptr_conv.is_owned = false;
35405         LDKPublicKey val_ref;
35406         CHECK((*env)->GetArrayLength(env, val) == 33);
35407         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35408         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
35409 }
35410
35411 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35412         LDKOpenChannel this_ptr_conv;
35413         this_ptr_conv.inner = untag_ptr(this_ptr);
35414         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35416         this_ptr_conv.is_owned = false;
35417         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35418         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
35419         return ret_arr;
35420 }
35421
35422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35423         LDKOpenChannel this_ptr_conv;
35424         this_ptr_conv.inner = untag_ptr(this_ptr);
35425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35427         this_ptr_conv.is_owned = false;
35428         LDKPublicKey val_ref;
35429         CHECK((*env)->GetArrayLength(env, val) == 33);
35430         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35431         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35432 }
35433
35434 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35435         LDKOpenChannel this_ptr_conv;
35436         this_ptr_conv.inner = untag_ptr(this_ptr);
35437         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35439         this_ptr_conv.is_owned = false;
35440         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35441         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
35442         return ret_arr;
35443 }
35444
35445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35446         LDKOpenChannel this_ptr_conv;
35447         this_ptr_conv.inner = untag_ptr(this_ptr);
35448         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35450         this_ptr_conv.is_owned = false;
35451         LDKPublicKey val_ref;
35452         CHECK((*env)->GetArrayLength(env, val) == 33);
35453         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35454         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
35455 }
35456
35457 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35458         LDKOpenChannel this_ptr_conv;
35459         this_ptr_conv.inner = untag_ptr(this_ptr);
35460         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35462         this_ptr_conv.is_owned = false;
35463         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35464         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
35465         return ret_arr;
35466 }
35467
35468 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) {
35469         LDKOpenChannel this_ptr_conv;
35470         this_ptr_conv.inner = untag_ptr(this_ptr);
35471         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35473         this_ptr_conv.is_owned = false;
35474         LDKPublicKey val_ref;
35475         CHECK((*env)->GetArrayLength(env, val) == 33);
35476         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35477         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
35478 }
35479
35480 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
35481         LDKOpenChannel this_ptr_conv;
35482         this_ptr_conv.inner = untag_ptr(this_ptr);
35483         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35485         this_ptr_conv.is_owned = false;
35486         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
35487         return ret_conv;
35488 }
35489
35490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
35491         LDKOpenChannel this_ptr_conv;
35492         this_ptr_conv.inner = untag_ptr(this_ptr);
35493         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35495         this_ptr_conv.is_owned = false;
35496         OpenChannel_set_channel_flags(&this_ptr_conv, val);
35497 }
35498
35499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
35500         LDKOpenChannel this_ptr_conv;
35501         this_ptr_conv.inner = untag_ptr(this_ptr);
35502         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35504         this_ptr_conv.is_owned = false;
35505         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
35506         int64_t ret_ref = 0;
35507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35508         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35509         return ret_ref;
35510 }
35511
35512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35513         LDKOpenChannel this_ptr_conv;
35514         this_ptr_conv.inner = untag_ptr(this_ptr);
35515         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35517         this_ptr_conv.is_owned = false;
35518         LDKChannelTypeFeatures val_conv;
35519         val_conv.inner = untag_ptr(val);
35520         val_conv.is_owned = ptr_is_owned(val);
35521         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35522         val_conv = ChannelTypeFeatures_clone(&val_conv);
35523         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
35524 }
35525
35526 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
35527         LDKOpenChannel ret_var = OpenChannel_clone(arg);
35528         int64_t ret_ref = 0;
35529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35530         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35531         return ret_ref;
35532 }
35533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35534         LDKOpenChannel arg_conv;
35535         arg_conv.inner = untag_ptr(arg);
35536         arg_conv.is_owned = ptr_is_owned(arg);
35537         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35538         arg_conv.is_owned = false;
35539         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
35540         return ret_conv;
35541 }
35542
35543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35544         LDKOpenChannel orig_conv;
35545         orig_conv.inner = untag_ptr(orig);
35546         orig_conv.is_owned = ptr_is_owned(orig);
35547         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35548         orig_conv.is_owned = false;
35549         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
35550         int64_t ret_ref = 0;
35551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35552         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35553         return ret_ref;
35554 }
35555
35556 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OpenChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35557         LDKOpenChannel a_conv;
35558         a_conv.inner = untag_ptr(a);
35559         a_conv.is_owned = ptr_is_owned(a);
35560         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35561         a_conv.is_owned = false;
35562         LDKOpenChannel b_conv;
35563         b_conv.inner = untag_ptr(b);
35564         b_conv.is_owned = ptr_is_owned(b);
35565         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35566         b_conv.is_owned = false;
35567         jboolean ret_conv = OpenChannel_eq(&a_conv, &b_conv);
35568         return ret_conv;
35569 }
35570
35571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35572         LDKAcceptChannel this_obj_conv;
35573         this_obj_conv.inner = untag_ptr(this_obj);
35574         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35576         AcceptChannel_free(this_obj_conv);
35577 }
35578
35579 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35580         LDKAcceptChannel this_ptr_conv;
35581         this_ptr_conv.inner = untag_ptr(this_ptr);
35582         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35584         this_ptr_conv.is_owned = false;
35585         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35586         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
35587         return ret_arr;
35588 }
35589
35590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35591         LDKAcceptChannel this_ptr_conv;
35592         this_ptr_conv.inner = untag_ptr(this_ptr);
35593         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35595         this_ptr_conv.is_owned = false;
35596         LDKThirtyTwoBytes val_ref;
35597         CHECK((*env)->GetArrayLength(env, val) == 32);
35598         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35599         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
35600 }
35601
35602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35603         LDKAcceptChannel this_ptr_conv;
35604         this_ptr_conv.inner = untag_ptr(this_ptr);
35605         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35607         this_ptr_conv.is_owned = false;
35608         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
35609         return ret_conv;
35610 }
35611
35612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35613         LDKAcceptChannel this_ptr_conv;
35614         this_ptr_conv.inner = untag_ptr(this_ptr);
35615         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35617         this_ptr_conv.is_owned = false;
35618         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
35619 }
35620
35621 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) {
35622         LDKAcceptChannel this_ptr_conv;
35623         this_ptr_conv.inner = untag_ptr(this_ptr);
35624         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35626         this_ptr_conv.is_owned = false;
35627         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
35628         return ret_conv;
35629 }
35630
35631 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) {
35632         LDKAcceptChannel this_ptr_conv;
35633         this_ptr_conv.inner = untag_ptr(this_ptr);
35634         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35636         this_ptr_conv.is_owned = false;
35637         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
35638 }
35639
35640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35641         LDKAcceptChannel this_ptr_conv;
35642         this_ptr_conv.inner = untag_ptr(this_ptr);
35643         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35645         this_ptr_conv.is_owned = false;
35646         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
35647         return ret_conv;
35648 }
35649
35650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35651         LDKAcceptChannel this_ptr_conv;
35652         this_ptr_conv.inner = untag_ptr(this_ptr);
35653         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35655         this_ptr_conv.is_owned = false;
35656         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
35657 }
35658
35659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35660         LDKAcceptChannel this_ptr_conv;
35661         this_ptr_conv.inner = untag_ptr(this_ptr);
35662         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35664         this_ptr_conv.is_owned = false;
35665         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
35666         return ret_conv;
35667 }
35668
35669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35670         LDKAcceptChannel this_ptr_conv;
35671         this_ptr_conv.inner = untag_ptr(this_ptr);
35672         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35674         this_ptr_conv.is_owned = false;
35675         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
35676 }
35677
35678 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
35679         LDKAcceptChannel this_ptr_conv;
35680         this_ptr_conv.inner = untag_ptr(this_ptr);
35681         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35683         this_ptr_conv.is_owned = false;
35684         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
35685         return ret_conv;
35686 }
35687
35688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35689         LDKAcceptChannel this_ptr_conv;
35690         this_ptr_conv.inner = untag_ptr(this_ptr);
35691         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35693         this_ptr_conv.is_owned = false;
35694         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
35695 }
35696
35697 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
35698         LDKAcceptChannel this_ptr_conv;
35699         this_ptr_conv.inner = untag_ptr(this_ptr);
35700         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35702         this_ptr_conv.is_owned = false;
35703         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
35704         return ret_conv;
35705 }
35706
35707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35708         LDKAcceptChannel this_ptr_conv;
35709         this_ptr_conv.inner = untag_ptr(this_ptr);
35710         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35712         this_ptr_conv.is_owned = false;
35713         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
35714 }
35715
35716 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35717         LDKAcceptChannel this_ptr_conv;
35718         this_ptr_conv.inner = untag_ptr(this_ptr);
35719         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35721         this_ptr_conv.is_owned = false;
35722         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
35723         return ret_conv;
35724 }
35725
35726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35727         LDKAcceptChannel this_ptr_conv;
35728         this_ptr_conv.inner = untag_ptr(this_ptr);
35729         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35731         this_ptr_conv.is_owned = false;
35732         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
35733 }
35734
35735 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
35736         LDKAcceptChannel this_ptr_conv;
35737         this_ptr_conv.inner = untag_ptr(this_ptr);
35738         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35740         this_ptr_conv.is_owned = false;
35741         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35742         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
35743         return ret_arr;
35744 }
35745
35746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35747         LDKAcceptChannel this_ptr_conv;
35748         this_ptr_conv.inner = untag_ptr(this_ptr);
35749         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35751         this_ptr_conv.is_owned = false;
35752         LDKPublicKey val_ref;
35753         CHECK((*env)->GetArrayLength(env, val) == 33);
35754         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35755         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
35756 }
35757
35758 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35759         LDKAcceptChannel this_ptr_conv;
35760         this_ptr_conv.inner = untag_ptr(this_ptr);
35761         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35763         this_ptr_conv.is_owned = false;
35764         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35765         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
35766         return ret_arr;
35767 }
35768
35769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35770         LDKAcceptChannel this_ptr_conv;
35771         this_ptr_conv.inner = untag_ptr(this_ptr);
35772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35774         this_ptr_conv.is_owned = false;
35775         LDKPublicKey val_ref;
35776         CHECK((*env)->GetArrayLength(env, val) == 33);
35777         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35778         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
35779 }
35780
35781 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35782         LDKAcceptChannel this_ptr_conv;
35783         this_ptr_conv.inner = untag_ptr(this_ptr);
35784         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35786         this_ptr_conv.is_owned = false;
35787         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35788         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
35789         return ret_arr;
35790 }
35791
35792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35793         LDKAcceptChannel this_ptr_conv;
35794         this_ptr_conv.inner = untag_ptr(this_ptr);
35795         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35797         this_ptr_conv.is_owned = false;
35798         LDKPublicKey val_ref;
35799         CHECK((*env)->GetArrayLength(env, val) == 33);
35800         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35801         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
35802 }
35803
35804 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35805         LDKAcceptChannel this_ptr_conv;
35806         this_ptr_conv.inner = untag_ptr(this_ptr);
35807         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35809         this_ptr_conv.is_owned = false;
35810         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35811         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
35812         return ret_arr;
35813 }
35814
35815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35816         LDKAcceptChannel this_ptr_conv;
35817         this_ptr_conv.inner = untag_ptr(this_ptr);
35818         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35820         this_ptr_conv.is_owned = false;
35821         LDKPublicKey val_ref;
35822         CHECK((*env)->GetArrayLength(env, val) == 33);
35823         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35824         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35825 }
35826
35827 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35828         LDKAcceptChannel this_ptr_conv;
35829         this_ptr_conv.inner = untag_ptr(this_ptr);
35830         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35832         this_ptr_conv.is_owned = false;
35833         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35834         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
35835         return ret_arr;
35836 }
35837
35838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35839         LDKAcceptChannel this_ptr_conv;
35840         this_ptr_conv.inner = untag_ptr(this_ptr);
35841         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35843         this_ptr_conv.is_owned = false;
35844         LDKPublicKey val_ref;
35845         CHECK((*env)->GetArrayLength(env, val) == 33);
35846         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35847         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
35848 }
35849
35850 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35851         LDKAcceptChannel this_ptr_conv;
35852         this_ptr_conv.inner = untag_ptr(this_ptr);
35853         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35855         this_ptr_conv.is_owned = false;
35856         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35857         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
35858         return ret_arr;
35859 }
35860
35861 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) {
35862         LDKAcceptChannel this_ptr_conv;
35863         this_ptr_conv.inner = untag_ptr(this_ptr);
35864         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35866         this_ptr_conv.is_owned = false;
35867         LDKPublicKey val_ref;
35868         CHECK((*env)->GetArrayLength(env, val) == 33);
35869         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35870         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
35871 }
35872
35873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
35874         LDKAcceptChannel this_ptr_conv;
35875         this_ptr_conv.inner = untag_ptr(this_ptr);
35876         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35878         this_ptr_conv.is_owned = false;
35879         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
35880         int64_t ret_ref = 0;
35881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35882         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35883         return ret_ref;
35884 }
35885
35886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
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         LDKChannelTypeFeatures val_conv;
35893         val_conv.inner = untag_ptr(val);
35894         val_conv.is_owned = ptr_is_owned(val);
35895         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35896         val_conv = ChannelTypeFeatures_clone(&val_conv);
35897         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
35898 }
35899
35900 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
35901         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
35902         int64_t ret_ref = 0;
35903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35905         return ret_ref;
35906 }
35907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35908         LDKAcceptChannel arg_conv;
35909         arg_conv.inner = untag_ptr(arg);
35910         arg_conv.is_owned = ptr_is_owned(arg);
35911         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35912         arg_conv.is_owned = false;
35913         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
35914         return ret_conv;
35915 }
35916
35917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35918         LDKAcceptChannel orig_conv;
35919         orig_conv.inner = untag_ptr(orig);
35920         orig_conv.is_owned = ptr_is_owned(orig);
35921         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35922         orig_conv.is_owned = false;
35923         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
35924         int64_t ret_ref = 0;
35925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35926         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35927         return ret_ref;
35928 }
35929
35930 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35931         LDKAcceptChannel a_conv;
35932         a_conv.inner = untag_ptr(a);
35933         a_conv.is_owned = ptr_is_owned(a);
35934         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35935         a_conv.is_owned = false;
35936         LDKAcceptChannel b_conv;
35937         b_conv.inner = untag_ptr(b);
35938         b_conv.is_owned = ptr_is_owned(b);
35939         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35940         b_conv.is_owned = false;
35941         jboolean ret_conv = AcceptChannel_eq(&a_conv, &b_conv);
35942         return ret_conv;
35943 }
35944
35945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35946         LDKFundingCreated this_obj_conv;
35947         this_obj_conv.inner = untag_ptr(this_obj);
35948         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35950         FundingCreated_free(this_obj_conv);
35951 }
35952
35953 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35954         LDKFundingCreated this_ptr_conv;
35955         this_ptr_conv.inner = untag_ptr(this_ptr);
35956         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35958         this_ptr_conv.is_owned = false;
35959         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35960         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
35961         return ret_arr;
35962 }
35963
35964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35965         LDKFundingCreated this_ptr_conv;
35966         this_ptr_conv.inner = untag_ptr(this_ptr);
35967         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35969         this_ptr_conv.is_owned = false;
35970         LDKThirtyTwoBytes val_ref;
35971         CHECK((*env)->GetArrayLength(env, val) == 32);
35972         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35973         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
35974 }
35975
35976 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
35977         LDKFundingCreated this_ptr_conv;
35978         this_ptr_conv.inner = untag_ptr(this_ptr);
35979         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35981         this_ptr_conv.is_owned = false;
35982         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35983         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
35984         return ret_arr;
35985 }
35986
35987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35988         LDKFundingCreated this_ptr_conv;
35989         this_ptr_conv.inner = untag_ptr(this_ptr);
35990         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35992         this_ptr_conv.is_owned = false;
35993         LDKThirtyTwoBytes val_ref;
35994         CHECK((*env)->GetArrayLength(env, val) == 32);
35995         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35996         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
35997 }
35998
35999 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
36000         LDKFundingCreated this_ptr_conv;
36001         this_ptr_conv.inner = untag_ptr(this_ptr);
36002         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36004         this_ptr_conv.is_owned = false;
36005         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
36006         return ret_conv;
36007 }
36008
36009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
36010         LDKFundingCreated this_ptr_conv;
36011         this_ptr_conv.inner = untag_ptr(this_ptr);
36012         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36014         this_ptr_conv.is_owned = false;
36015         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
36016 }
36017
36018 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36019         LDKFundingCreated this_ptr_conv;
36020         this_ptr_conv.inner = untag_ptr(this_ptr);
36021         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36023         this_ptr_conv.is_owned = false;
36024         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36025         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
36026         return ret_arr;
36027 }
36028
36029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36030         LDKFundingCreated this_ptr_conv;
36031         this_ptr_conv.inner = untag_ptr(this_ptr);
36032         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36034         this_ptr_conv.is_owned = false;
36035         LDKSignature val_ref;
36036         CHECK((*env)->GetArrayLength(env, val) == 64);
36037         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36038         FundingCreated_set_signature(&this_ptr_conv, val_ref);
36039 }
36040
36041 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) {
36042         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
36043         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
36044         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
36045         LDKThirtyTwoBytes funding_txid_arg_ref;
36046         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
36047         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
36048         LDKSignature signature_arg_ref;
36049         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36050         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36051         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
36052         int64_t ret_ref = 0;
36053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36054         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36055         return ret_ref;
36056 }
36057
36058 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
36059         LDKFundingCreated ret_var = FundingCreated_clone(arg);
36060         int64_t ret_ref = 0;
36061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36062         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36063         return ret_ref;
36064 }
36065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36066         LDKFundingCreated arg_conv;
36067         arg_conv.inner = untag_ptr(arg);
36068         arg_conv.is_owned = ptr_is_owned(arg);
36069         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36070         arg_conv.is_owned = false;
36071         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
36072         return ret_conv;
36073 }
36074
36075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36076         LDKFundingCreated orig_conv;
36077         orig_conv.inner = untag_ptr(orig);
36078         orig_conv.is_owned = ptr_is_owned(orig);
36079         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36080         orig_conv.is_owned = false;
36081         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
36082         int64_t ret_ref = 0;
36083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36084         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36085         return ret_ref;
36086 }
36087
36088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingCreated_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36089         LDKFundingCreated a_conv;
36090         a_conv.inner = untag_ptr(a);
36091         a_conv.is_owned = ptr_is_owned(a);
36092         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36093         a_conv.is_owned = false;
36094         LDKFundingCreated b_conv;
36095         b_conv.inner = untag_ptr(b);
36096         b_conv.is_owned = ptr_is_owned(b);
36097         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36098         b_conv.is_owned = false;
36099         jboolean ret_conv = FundingCreated_eq(&a_conv, &b_conv);
36100         return ret_conv;
36101 }
36102
36103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36104         LDKFundingSigned this_obj_conv;
36105         this_obj_conv.inner = untag_ptr(this_obj);
36106         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36108         FundingSigned_free(this_obj_conv);
36109 }
36110
36111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36112         LDKFundingSigned this_ptr_conv;
36113         this_ptr_conv.inner = untag_ptr(this_ptr);
36114         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36116         this_ptr_conv.is_owned = false;
36117         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36118         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
36119         return ret_arr;
36120 }
36121
36122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36123         LDKFundingSigned this_ptr_conv;
36124         this_ptr_conv.inner = untag_ptr(this_ptr);
36125         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36127         this_ptr_conv.is_owned = false;
36128         LDKThirtyTwoBytes val_ref;
36129         CHECK((*env)->GetArrayLength(env, val) == 32);
36130         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36131         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
36132 }
36133
36134 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36135         LDKFundingSigned this_ptr_conv;
36136         this_ptr_conv.inner = untag_ptr(this_ptr);
36137         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36139         this_ptr_conv.is_owned = false;
36140         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36141         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
36142         return ret_arr;
36143 }
36144
36145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36146         LDKFundingSigned this_ptr_conv;
36147         this_ptr_conv.inner = untag_ptr(this_ptr);
36148         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36150         this_ptr_conv.is_owned = false;
36151         LDKSignature val_ref;
36152         CHECK((*env)->GetArrayLength(env, val) == 64);
36153         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36154         FundingSigned_set_signature(&this_ptr_conv, val_ref);
36155 }
36156
36157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
36158         LDKThirtyTwoBytes channel_id_arg_ref;
36159         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36160         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36161         LDKSignature signature_arg_ref;
36162         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36163         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36164         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
36165         int64_t ret_ref = 0;
36166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36167         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36168         return ret_ref;
36169 }
36170
36171 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
36172         LDKFundingSigned ret_var = FundingSigned_clone(arg);
36173         int64_t ret_ref = 0;
36174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36175         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36176         return ret_ref;
36177 }
36178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36179         LDKFundingSigned arg_conv;
36180         arg_conv.inner = untag_ptr(arg);
36181         arg_conv.is_owned = ptr_is_owned(arg);
36182         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36183         arg_conv.is_owned = false;
36184         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
36185         return ret_conv;
36186 }
36187
36188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36189         LDKFundingSigned orig_conv;
36190         orig_conv.inner = untag_ptr(orig);
36191         orig_conv.is_owned = ptr_is_owned(orig);
36192         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36193         orig_conv.is_owned = false;
36194         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
36195         int64_t ret_ref = 0;
36196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36197         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36198         return ret_ref;
36199 }
36200
36201 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36202         LDKFundingSigned a_conv;
36203         a_conv.inner = untag_ptr(a);
36204         a_conv.is_owned = ptr_is_owned(a);
36205         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36206         a_conv.is_owned = false;
36207         LDKFundingSigned b_conv;
36208         b_conv.inner = untag_ptr(b);
36209         b_conv.is_owned = ptr_is_owned(b);
36210         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36211         b_conv.is_owned = false;
36212         jboolean ret_conv = FundingSigned_eq(&a_conv, &b_conv);
36213         return ret_conv;
36214 }
36215
36216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36217         LDKChannelReady this_obj_conv;
36218         this_obj_conv.inner = untag_ptr(this_obj);
36219         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36221         ChannelReady_free(this_obj_conv);
36222 }
36223
36224 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36225         LDKChannelReady this_ptr_conv;
36226         this_ptr_conv.inner = untag_ptr(this_ptr);
36227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36229         this_ptr_conv.is_owned = false;
36230         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36231         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
36232         return ret_arr;
36233 }
36234
36235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36236         LDKChannelReady this_ptr_conv;
36237         this_ptr_conv.inner = untag_ptr(this_ptr);
36238         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36240         this_ptr_conv.is_owned = false;
36241         LDKThirtyTwoBytes val_ref;
36242         CHECK((*env)->GetArrayLength(env, val) == 32);
36243         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36244         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
36245 }
36246
36247 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36248         LDKChannelReady this_ptr_conv;
36249         this_ptr_conv.inner = untag_ptr(this_ptr);
36250         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36252         this_ptr_conv.is_owned = false;
36253         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36254         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
36255         return ret_arr;
36256 }
36257
36258 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) {
36259         LDKChannelReady this_ptr_conv;
36260         this_ptr_conv.inner = untag_ptr(this_ptr);
36261         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36263         this_ptr_conv.is_owned = false;
36264         LDKPublicKey val_ref;
36265         CHECK((*env)->GetArrayLength(env, val) == 33);
36266         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36267         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
36268 }
36269
36270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
36271         LDKChannelReady this_ptr_conv;
36272         this_ptr_conv.inner = untag_ptr(this_ptr);
36273         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36275         this_ptr_conv.is_owned = false;
36276         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36277         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
36278         int64_t ret_ref = tag_ptr(ret_copy, true);
36279         return ret_ref;
36280 }
36281
36282 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) {
36283         LDKChannelReady this_ptr_conv;
36284         this_ptr_conv.inner = untag_ptr(this_ptr);
36285         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36287         this_ptr_conv.is_owned = false;
36288         void* val_ptr = untag_ptr(val);
36289         CHECK_ACCESS(val_ptr);
36290         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
36291         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
36292         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
36293 }
36294
36295 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) {
36296         LDKThirtyTwoBytes channel_id_arg_ref;
36297         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36298         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36299         LDKPublicKey next_per_commitment_point_arg_ref;
36300         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
36301         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
36302         void* short_channel_id_alias_arg_ptr = untag_ptr(short_channel_id_alias_arg);
36303         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
36304         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
36305         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_alias_arg));
36306         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
36307         int64_t ret_ref = 0;
36308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36309         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36310         return ret_ref;
36311 }
36312
36313 static inline uint64_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
36314         LDKChannelReady ret_var = ChannelReady_clone(arg);
36315         int64_t ret_ref = 0;
36316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36317         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36318         return ret_ref;
36319 }
36320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36321         LDKChannelReady arg_conv;
36322         arg_conv.inner = untag_ptr(arg);
36323         arg_conv.is_owned = ptr_is_owned(arg);
36324         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36325         arg_conv.is_owned = false;
36326         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
36327         return ret_conv;
36328 }
36329
36330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36331         LDKChannelReady orig_conv;
36332         orig_conv.inner = untag_ptr(orig);
36333         orig_conv.is_owned = ptr_is_owned(orig);
36334         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36335         orig_conv.is_owned = false;
36336         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
36337         int64_t ret_ref = 0;
36338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36339         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36340         return ret_ref;
36341 }
36342
36343 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReady_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36344         LDKChannelReady a_conv;
36345         a_conv.inner = untag_ptr(a);
36346         a_conv.is_owned = ptr_is_owned(a);
36347         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36348         a_conv.is_owned = false;
36349         LDKChannelReady b_conv;
36350         b_conv.inner = untag_ptr(b);
36351         b_conv.is_owned = ptr_is_owned(b);
36352         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36353         b_conv.is_owned = false;
36354         jboolean ret_conv = ChannelReady_eq(&a_conv, &b_conv);
36355         return ret_conv;
36356 }
36357
36358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36359         LDKShutdown this_obj_conv;
36360         this_obj_conv.inner = untag_ptr(this_obj);
36361         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36363         Shutdown_free(this_obj_conv);
36364 }
36365
36366 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36367         LDKShutdown this_ptr_conv;
36368         this_ptr_conv.inner = untag_ptr(this_ptr);
36369         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36371         this_ptr_conv.is_owned = false;
36372         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36373         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
36374         return ret_arr;
36375 }
36376
36377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36378         LDKShutdown this_ptr_conv;
36379         this_ptr_conv.inner = untag_ptr(this_ptr);
36380         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36382         this_ptr_conv.is_owned = false;
36383         LDKThirtyTwoBytes val_ref;
36384         CHECK((*env)->GetArrayLength(env, val) == 32);
36385         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36386         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
36387 }
36388
36389 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
36390         LDKShutdown this_ptr_conv;
36391         this_ptr_conv.inner = untag_ptr(this_ptr);
36392         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36394         this_ptr_conv.is_owned = false;
36395         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
36396         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36397         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36398         return ret_arr;
36399 }
36400
36401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36402         LDKShutdown this_ptr_conv;
36403         this_ptr_conv.inner = untag_ptr(this_ptr);
36404         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36406         this_ptr_conv.is_owned = false;
36407         LDKCVec_u8Z val_ref;
36408         val_ref.datalen = (*env)->GetArrayLength(env, val);
36409         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
36410         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
36411         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
36412 }
36413
36414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
36415         LDKThirtyTwoBytes channel_id_arg_ref;
36416         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36417         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36418         LDKCVec_u8Z scriptpubkey_arg_ref;
36419         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
36420         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
36421         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
36422         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
36423         int64_t ret_ref = 0;
36424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36425         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36426         return ret_ref;
36427 }
36428
36429 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
36430         LDKShutdown ret_var = Shutdown_clone(arg);
36431         int64_t ret_ref = 0;
36432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36433         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36434         return ret_ref;
36435 }
36436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36437         LDKShutdown arg_conv;
36438         arg_conv.inner = untag_ptr(arg);
36439         arg_conv.is_owned = ptr_is_owned(arg);
36440         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36441         arg_conv.is_owned = false;
36442         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
36443         return ret_conv;
36444 }
36445
36446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36447         LDKShutdown orig_conv;
36448         orig_conv.inner = untag_ptr(orig);
36449         orig_conv.is_owned = ptr_is_owned(orig);
36450         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36451         orig_conv.is_owned = false;
36452         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
36453         int64_t ret_ref = 0;
36454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36455         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36456         return ret_ref;
36457 }
36458
36459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Shutdown_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36460         LDKShutdown a_conv;
36461         a_conv.inner = untag_ptr(a);
36462         a_conv.is_owned = ptr_is_owned(a);
36463         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36464         a_conv.is_owned = false;
36465         LDKShutdown b_conv;
36466         b_conv.inner = untag_ptr(b);
36467         b_conv.is_owned = ptr_is_owned(b);
36468         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36469         b_conv.is_owned = false;
36470         jboolean ret_conv = Shutdown_eq(&a_conv, &b_conv);
36471         return ret_conv;
36472 }
36473
36474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36475         LDKClosingSignedFeeRange this_obj_conv;
36476         this_obj_conv.inner = untag_ptr(this_obj);
36477         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36479         ClosingSignedFeeRange_free(this_obj_conv);
36480 }
36481
36482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
36483         LDKClosingSignedFeeRange this_ptr_conv;
36484         this_ptr_conv.inner = untag_ptr(this_ptr);
36485         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36487         this_ptr_conv.is_owned = false;
36488         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
36489         return ret_conv;
36490 }
36491
36492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36493         LDKClosingSignedFeeRange this_ptr_conv;
36494         this_ptr_conv.inner = untag_ptr(this_ptr);
36495         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36497         this_ptr_conv.is_owned = false;
36498         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
36499 }
36500
36501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
36502         LDKClosingSignedFeeRange this_ptr_conv;
36503         this_ptr_conv.inner = untag_ptr(this_ptr);
36504         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36506         this_ptr_conv.is_owned = false;
36507         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
36508         return ret_conv;
36509 }
36510
36511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36512         LDKClosingSignedFeeRange this_ptr_conv;
36513         this_ptr_conv.inner = untag_ptr(this_ptr);
36514         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36516         this_ptr_conv.is_owned = false;
36517         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
36518 }
36519
36520 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) {
36521         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
36522         int64_t ret_ref = 0;
36523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36524         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36525         return ret_ref;
36526 }
36527
36528 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
36529         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
36530         int64_t ret_ref = 0;
36531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36532         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36533         return ret_ref;
36534 }
36535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36536         LDKClosingSignedFeeRange arg_conv;
36537         arg_conv.inner = untag_ptr(arg);
36538         arg_conv.is_owned = ptr_is_owned(arg);
36539         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36540         arg_conv.is_owned = false;
36541         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
36542         return ret_conv;
36543 }
36544
36545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36546         LDKClosingSignedFeeRange orig_conv;
36547         orig_conv.inner = untag_ptr(orig);
36548         orig_conv.is_owned = ptr_is_owned(orig);
36549         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36550         orig_conv.is_owned = false;
36551         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
36552         int64_t ret_ref = 0;
36553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36554         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36555         return ret_ref;
36556 }
36557
36558 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36559         LDKClosingSignedFeeRange a_conv;
36560         a_conv.inner = untag_ptr(a);
36561         a_conv.is_owned = ptr_is_owned(a);
36562         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36563         a_conv.is_owned = false;
36564         LDKClosingSignedFeeRange b_conv;
36565         b_conv.inner = untag_ptr(b);
36566         b_conv.is_owned = ptr_is_owned(b);
36567         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36568         b_conv.is_owned = false;
36569         jboolean ret_conv = ClosingSignedFeeRange_eq(&a_conv, &b_conv);
36570         return ret_conv;
36571 }
36572
36573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36574         LDKClosingSigned this_obj_conv;
36575         this_obj_conv.inner = untag_ptr(this_obj);
36576         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36578         ClosingSigned_free(this_obj_conv);
36579 }
36580
36581 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36582         LDKClosingSigned this_ptr_conv;
36583         this_ptr_conv.inner = untag_ptr(this_ptr);
36584         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36586         this_ptr_conv.is_owned = false;
36587         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36588         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
36589         return ret_arr;
36590 }
36591
36592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36593         LDKClosingSigned this_ptr_conv;
36594         this_ptr_conv.inner = untag_ptr(this_ptr);
36595         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36597         this_ptr_conv.is_owned = false;
36598         LDKThirtyTwoBytes val_ref;
36599         CHECK((*env)->GetArrayLength(env, val) == 32);
36600         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36601         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
36602 }
36603
36604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
36605         LDKClosingSigned this_ptr_conv;
36606         this_ptr_conv.inner = untag_ptr(this_ptr);
36607         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36609         this_ptr_conv.is_owned = false;
36610         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
36611         return ret_conv;
36612 }
36613
36614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36615         LDKClosingSigned this_ptr_conv;
36616         this_ptr_conv.inner = untag_ptr(this_ptr);
36617         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36619         this_ptr_conv.is_owned = false;
36620         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
36621 }
36622
36623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36624         LDKClosingSigned this_ptr_conv;
36625         this_ptr_conv.inner = untag_ptr(this_ptr);
36626         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36628         this_ptr_conv.is_owned = false;
36629         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36630         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
36631         return ret_arr;
36632 }
36633
36634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36635         LDKClosingSigned this_ptr_conv;
36636         this_ptr_conv.inner = untag_ptr(this_ptr);
36637         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36639         this_ptr_conv.is_owned = false;
36640         LDKSignature val_ref;
36641         CHECK((*env)->GetArrayLength(env, val) == 64);
36642         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36643         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
36644 }
36645
36646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
36647         LDKClosingSigned this_ptr_conv;
36648         this_ptr_conv.inner = untag_ptr(this_ptr);
36649         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36651         this_ptr_conv.is_owned = false;
36652         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
36653         int64_t ret_ref = 0;
36654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36655         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36656         return ret_ref;
36657 }
36658
36659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36660         LDKClosingSigned this_ptr_conv;
36661         this_ptr_conv.inner = untag_ptr(this_ptr);
36662         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36664         this_ptr_conv.is_owned = false;
36665         LDKClosingSignedFeeRange val_conv;
36666         val_conv.inner = untag_ptr(val);
36667         val_conv.is_owned = ptr_is_owned(val);
36668         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36669         val_conv = ClosingSignedFeeRange_clone(&val_conv);
36670         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
36671 }
36672
36673 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) {
36674         LDKThirtyTwoBytes channel_id_arg_ref;
36675         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36676         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36677         LDKSignature signature_arg_ref;
36678         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36679         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36680         LDKClosingSignedFeeRange fee_range_arg_conv;
36681         fee_range_arg_conv.inner = untag_ptr(fee_range_arg);
36682         fee_range_arg_conv.is_owned = ptr_is_owned(fee_range_arg);
36683         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
36684         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
36685         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
36686         int64_t ret_ref = 0;
36687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36688         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36689         return ret_ref;
36690 }
36691
36692 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
36693         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
36694         int64_t ret_ref = 0;
36695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36696         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36697         return ret_ref;
36698 }
36699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36700         LDKClosingSigned arg_conv;
36701         arg_conv.inner = untag_ptr(arg);
36702         arg_conv.is_owned = ptr_is_owned(arg);
36703         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36704         arg_conv.is_owned = false;
36705         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
36706         return ret_conv;
36707 }
36708
36709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36710         LDKClosingSigned orig_conv;
36711         orig_conv.inner = untag_ptr(orig);
36712         orig_conv.is_owned = ptr_is_owned(orig);
36713         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36714         orig_conv.is_owned = false;
36715         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
36716         int64_t ret_ref = 0;
36717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36718         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36719         return ret_ref;
36720 }
36721
36722 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36723         LDKClosingSigned a_conv;
36724         a_conv.inner = untag_ptr(a);
36725         a_conv.is_owned = ptr_is_owned(a);
36726         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36727         a_conv.is_owned = false;
36728         LDKClosingSigned b_conv;
36729         b_conv.inner = untag_ptr(b);
36730         b_conv.is_owned = ptr_is_owned(b);
36731         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36732         b_conv.is_owned = false;
36733         jboolean ret_conv = ClosingSigned_eq(&a_conv, &b_conv);
36734         return ret_conv;
36735 }
36736
36737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36738         LDKUpdateAddHTLC this_obj_conv;
36739         this_obj_conv.inner = untag_ptr(this_obj);
36740         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36742         UpdateAddHTLC_free(this_obj_conv);
36743 }
36744
36745 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36746         LDKUpdateAddHTLC this_ptr_conv;
36747         this_ptr_conv.inner = untag_ptr(this_ptr);
36748         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36750         this_ptr_conv.is_owned = false;
36751         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36752         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
36753         return ret_arr;
36754 }
36755
36756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36757         LDKUpdateAddHTLC this_ptr_conv;
36758         this_ptr_conv.inner = untag_ptr(this_ptr);
36759         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36761         this_ptr_conv.is_owned = false;
36762         LDKThirtyTwoBytes val_ref;
36763         CHECK((*env)->GetArrayLength(env, val) == 32);
36764         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36765         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
36766 }
36767
36768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36769         LDKUpdateAddHTLC this_ptr_conv;
36770         this_ptr_conv.inner = untag_ptr(this_ptr);
36771         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36773         this_ptr_conv.is_owned = false;
36774         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
36775         return ret_conv;
36776 }
36777
36778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36779         LDKUpdateAddHTLC this_ptr_conv;
36780         this_ptr_conv.inner = untag_ptr(this_ptr);
36781         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36783         this_ptr_conv.is_owned = false;
36784         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
36785 }
36786
36787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36788         LDKUpdateAddHTLC this_ptr_conv;
36789         this_ptr_conv.inner = untag_ptr(this_ptr);
36790         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36792         this_ptr_conv.is_owned = false;
36793         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
36794         return ret_conv;
36795 }
36796
36797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36798         LDKUpdateAddHTLC this_ptr_conv;
36799         this_ptr_conv.inner = untag_ptr(this_ptr);
36800         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36802         this_ptr_conv.is_owned = false;
36803         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
36804 }
36805
36806 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36807         LDKUpdateAddHTLC this_ptr_conv;
36808         this_ptr_conv.inner = untag_ptr(this_ptr);
36809         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36811         this_ptr_conv.is_owned = false;
36812         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36813         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
36814         return ret_arr;
36815 }
36816
36817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36818         LDKUpdateAddHTLC this_ptr_conv;
36819         this_ptr_conv.inner = untag_ptr(this_ptr);
36820         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36822         this_ptr_conv.is_owned = false;
36823         LDKThirtyTwoBytes val_ref;
36824         CHECK((*env)->GetArrayLength(env, val) == 32);
36825         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36826         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
36827 }
36828
36829 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
36830         LDKUpdateAddHTLC this_ptr_conv;
36831         this_ptr_conv.inner = untag_ptr(this_ptr);
36832         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36834         this_ptr_conv.is_owned = false;
36835         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
36836         return ret_conv;
36837 }
36838
36839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36840         LDKUpdateAddHTLC this_ptr_conv;
36841         this_ptr_conv.inner = untag_ptr(this_ptr);
36842         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36844         this_ptr_conv.is_owned = false;
36845         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
36846 }
36847
36848 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
36849         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
36850         int64_t ret_ref = 0;
36851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36852         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36853         return ret_ref;
36854 }
36855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36856         LDKUpdateAddHTLC arg_conv;
36857         arg_conv.inner = untag_ptr(arg);
36858         arg_conv.is_owned = ptr_is_owned(arg);
36859         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36860         arg_conv.is_owned = false;
36861         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
36862         return ret_conv;
36863 }
36864
36865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36866         LDKUpdateAddHTLC orig_conv;
36867         orig_conv.inner = untag_ptr(orig);
36868         orig_conv.is_owned = ptr_is_owned(orig);
36869         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36870         orig_conv.is_owned = false;
36871         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
36872         int64_t ret_ref = 0;
36873         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36874         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36875         return ret_ref;
36876 }
36877
36878 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36879         LDKUpdateAddHTLC a_conv;
36880         a_conv.inner = untag_ptr(a);
36881         a_conv.is_owned = ptr_is_owned(a);
36882         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36883         a_conv.is_owned = false;
36884         LDKUpdateAddHTLC b_conv;
36885         b_conv.inner = untag_ptr(b);
36886         b_conv.is_owned = ptr_is_owned(b);
36887         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36888         b_conv.is_owned = false;
36889         jboolean ret_conv = UpdateAddHTLC_eq(&a_conv, &b_conv);
36890         return ret_conv;
36891 }
36892
36893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36894         LDKOnionMessage this_obj_conv;
36895         this_obj_conv.inner = untag_ptr(this_obj);
36896         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36898         OnionMessage_free(this_obj_conv);
36899 }
36900
36901 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1get_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36902         LDKOnionMessage this_ptr_conv;
36903         this_ptr_conv.inner = untag_ptr(this_ptr);
36904         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36906         this_ptr_conv.is_owned = false;
36907         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36908         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OnionMessage_get_blinding_point(&this_ptr_conv).compressed_form);
36909         return ret_arr;
36910 }
36911
36912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1set_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36913         LDKOnionMessage this_ptr_conv;
36914         this_ptr_conv.inner = untag_ptr(this_ptr);
36915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36917         this_ptr_conv.is_owned = false;
36918         LDKPublicKey val_ref;
36919         CHECK((*env)->GetArrayLength(env, val) == 33);
36920         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36921         OnionMessage_set_blinding_point(&this_ptr_conv, val_ref);
36922 }
36923
36924 static inline uint64_t OnionMessage_clone_ptr(LDKOnionMessage *NONNULL_PTR arg) {
36925         LDKOnionMessage ret_var = OnionMessage_clone(arg);
36926         int64_t ret_ref = 0;
36927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36928         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36929         return ret_ref;
36930 }
36931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36932         LDKOnionMessage arg_conv;
36933         arg_conv.inner = untag_ptr(arg);
36934         arg_conv.is_owned = ptr_is_owned(arg);
36935         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36936         arg_conv.is_owned = false;
36937         int64_t ret_conv = OnionMessage_clone_ptr(&arg_conv);
36938         return ret_conv;
36939 }
36940
36941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36942         LDKOnionMessage orig_conv;
36943         orig_conv.inner = untag_ptr(orig);
36944         orig_conv.is_owned = ptr_is_owned(orig);
36945         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36946         orig_conv.is_owned = false;
36947         LDKOnionMessage ret_var = OnionMessage_clone(&orig_conv);
36948         int64_t ret_ref = 0;
36949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36950         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36951         return ret_ref;
36952 }
36953
36954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OnionMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36955         LDKOnionMessage a_conv;
36956         a_conv.inner = untag_ptr(a);
36957         a_conv.is_owned = ptr_is_owned(a);
36958         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36959         a_conv.is_owned = false;
36960         LDKOnionMessage b_conv;
36961         b_conv.inner = untag_ptr(b);
36962         b_conv.is_owned = ptr_is_owned(b);
36963         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36964         b_conv.is_owned = false;
36965         jboolean ret_conv = OnionMessage_eq(&a_conv, &b_conv);
36966         return ret_conv;
36967 }
36968
36969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36970         LDKUpdateFulfillHTLC this_obj_conv;
36971         this_obj_conv.inner = untag_ptr(this_obj);
36972         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36974         UpdateFulfillHTLC_free(this_obj_conv);
36975 }
36976
36977 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36978         LDKUpdateFulfillHTLC this_ptr_conv;
36979         this_ptr_conv.inner = untag_ptr(this_ptr);
36980         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36982         this_ptr_conv.is_owned = false;
36983         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36984         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
36985         return ret_arr;
36986 }
36987
36988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36989         LDKUpdateFulfillHTLC this_ptr_conv;
36990         this_ptr_conv.inner = untag_ptr(this_ptr);
36991         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36993         this_ptr_conv.is_owned = false;
36994         LDKThirtyTwoBytes val_ref;
36995         CHECK((*env)->GetArrayLength(env, val) == 32);
36996         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36997         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
36998 }
36999
37000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37001         LDKUpdateFulfillHTLC this_ptr_conv;
37002         this_ptr_conv.inner = untag_ptr(this_ptr);
37003         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37005         this_ptr_conv.is_owned = false;
37006         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
37007         return ret_conv;
37008 }
37009
37010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37011         LDKUpdateFulfillHTLC this_ptr_conv;
37012         this_ptr_conv.inner = untag_ptr(this_ptr);
37013         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37015         this_ptr_conv.is_owned = false;
37016         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
37017 }
37018
37019 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
37020         LDKUpdateFulfillHTLC this_ptr_conv;
37021         this_ptr_conv.inner = untag_ptr(this_ptr);
37022         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37024         this_ptr_conv.is_owned = false;
37025         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37026         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
37027         return ret_arr;
37028 }
37029
37030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37031         LDKUpdateFulfillHTLC this_ptr_conv;
37032         this_ptr_conv.inner = untag_ptr(this_ptr);
37033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37035         this_ptr_conv.is_owned = false;
37036         LDKThirtyTwoBytes val_ref;
37037         CHECK((*env)->GetArrayLength(env, val) == 32);
37038         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37039         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
37040 }
37041
37042 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) {
37043         LDKThirtyTwoBytes channel_id_arg_ref;
37044         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37045         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37046         LDKThirtyTwoBytes payment_preimage_arg_ref;
37047         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
37048         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
37049         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
37050         int64_t ret_ref = 0;
37051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37052         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37053         return ret_ref;
37054 }
37055
37056 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
37057         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
37058         int64_t ret_ref = 0;
37059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37060         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37061         return ret_ref;
37062 }
37063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37064         LDKUpdateFulfillHTLC arg_conv;
37065         arg_conv.inner = untag_ptr(arg);
37066         arg_conv.is_owned = ptr_is_owned(arg);
37067         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37068         arg_conv.is_owned = false;
37069         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
37070         return ret_conv;
37071 }
37072
37073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37074         LDKUpdateFulfillHTLC orig_conv;
37075         orig_conv.inner = untag_ptr(orig);
37076         orig_conv.is_owned = ptr_is_owned(orig);
37077         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37078         orig_conv.is_owned = false;
37079         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
37080         int64_t ret_ref = 0;
37081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37082         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37083         return ret_ref;
37084 }
37085
37086 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37087         LDKUpdateFulfillHTLC a_conv;
37088         a_conv.inner = untag_ptr(a);
37089         a_conv.is_owned = ptr_is_owned(a);
37090         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37091         a_conv.is_owned = false;
37092         LDKUpdateFulfillHTLC b_conv;
37093         b_conv.inner = untag_ptr(b);
37094         b_conv.is_owned = ptr_is_owned(b);
37095         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37096         b_conv.is_owned = false;
37097         jboolean ret_conv = UpdateFulfillHTLC_eq(&a_conv, &b_conv);
37098         return ret_conv;
37099 }
37100
37101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37102         LDKUpdateFailHTLC this_obj_conv;
37103         this_obj_conv.inner = untag_ptr(this_obj);
37104         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37106         UpdateFailHTLC_free(this_obj_conv);
37107 }
37108
37109 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37110         LDKUpdateFailHTLC this_ptr_conv;
37111         this_ptr_conv.inner = untag_ptr(this_ptr);
37112         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37114         this_ptr_conv.is_owned = false;
37115         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37116         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
37117         return ret_arr;
37118 }
37119
37120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37121         LDKUpdateFailHTLC this_ptr_conv;
37122         this_ptr_conv.inner = untag_ptr(this_ptr);
37123         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37125         this_ptr_conv.is_owned = false;
37126         LDKThirtyTwoBytes val_ref;
37127         CHECK((*env)->GetArrayLength(env, val) == 32);
37128         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37129         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
37130 }
37131
37132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37133         LDKUpdateFailHTLC this_ptr_conv;
37134         this_ptr_conv.inner = untag_ptr(this_ptr);
37135         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37137         this_ptr_conv.is_owned = false;
37138         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
37139         return ret_conv;
37140 }
37141
37142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37143         LDKUpdateFailHTLC this_ptr_conv;
37144         this_ptr_conv.inner = untag_ptr(this_ptr);
37145         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37147         this_ptr_conv.is_owned = false;
37148         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
37149 }
37150
37151 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
37152         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
37153         int64_t ret_ref = 0;
37154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37155         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37156         return ret_ref;
37157 }
37158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37159         LDKUpdateFailHTLC arg_conv;
37160         arg_conv.inner = untag_ptr(arg);
37161         arg_conv.is_owned = ptr_is_owned(arg);
37162         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37163         arg_conv.is_owned = false;
37164         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
37165         return ret_conv;
37166 }
37167
37168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37169         LDKUpdateFailHTLC orig_conv;
37170         orig_conv.inner = untag_ptr(orig);
37171         orig_conv.is_owned = ptr_is_owned(orig);
37172         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37173         orig_conv.is_owned = false;
37174         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
37175         int64_t ret_ref = 0;
37176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37177         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37178         return ret_ref;
37179 }
37180
37181 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37182         LDKUpdateFailHTLC a_conv;
37183         a_conv.inner = untag_ptr(a);
37184         a_conv.is_owned = ptr_is_owned(a);
37185         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37186         a_conv.is_owned = false;
37187         LDKUpdateFailHTLC b_conv;
37188         b_conv.inner = untag_ptr(b);
37189         b_conv.is_owned = ptr_is_owned(b);
37190         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37191         b_conv.is_owned = false;
37192         jboolean ret_conv = UpdateFailHTLC_eq(&a_conv, &b_conv);
37193         return ret_conv;
37194 }
37195
37196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37197         LDKUpdateFailMalformedHTLC this_obj_conv;
37198         this_obj_conv.inner = untag_ptr(this_obj);
37199         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37201         UpdateFailMalformedHTLC_free(this_obj_conv);
37202 }
37203
37204 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37205         LDKUpdateFailMalformedHTLC this_ptr_conv;
37206         this_ptr_conv.inner = untag_ptr(this_ptr);
37207         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37209         this_ptr_conv.is_owned = false;
37210         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37211         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
37212         return ret_arr;
37213 }
37214
37215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37216         LDKUpdateFailMalformedHTLC this_ptr_conv;
37217         this_ptr_conv.inner = untag_ptr(this_ptr);
37218         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37220         this_ptr_conv.is_owned = false;
37221         LDKThirtyTwoBytes val_ref;
37222         CHECK((*env)->GetArrayLength(env, val) == 32);
37223         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37224         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
37225 }
37226
37227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37228         LDKUpdateFailMalformedHTLC this_ptr_conv;
37229         this_ptr_conv.inner = untag_ptr(this_ptr);
37230         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37232         this_ptr_conv.is_owned = false;
37233         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
37234         return ret_conv;
37235 }
37236
37237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37238         LDKUpdateFailMalformedHTLC this_ptr_conv;
37239         this_ptr_conv.inner = untag_ptr(this_ptr);
37240         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37242         this_ptr_conv.is_owned = false;
37243         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
37244 }
37245
37246 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
37247         LDKUpdateFailMalformedHTLC this_ptr_conv;
37248         this_ptr_conv.inner = untag_ptr(this_ptr);
37249         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37251         this_ptr_conv.is_owned = false;
37252         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
37253         return ret_conv;
37254 }
37255
37256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
37257         LDKUpdateFailMalformedHTLC this_ptr_conv;
37258         this_ptr_conv.inner = untag_ptr(this_ptr);
37259         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37261         this_ptr_conv.is_owned = false;
37262         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
37263 }
37264
37265 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
37266         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
37267         int64_t ret_ref = 0;
37268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37269         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37270         return ret_ref;
37271 }
37272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37273         LDKUpdateFailMalformedHTLC arg_conv;
37274         arg_conv.inner = untag_ptr(arg);
37275         arg_conv.is_owned = ptr_is_owned(arg);
37276         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37277         arg_conv.is_owned = false;
37278         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
37279         return ret_conv;
37280 }
37281
37282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37283         LDKUpdateFailMalformedHTLC orig_conv;
37284         orig_conv.inner = untag_ptr(orig);
37285         orig_conv.is_owned = ptr_is_owned(orig);
37286         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37287         orig_conv.is_owned = false;
37288         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
37289         int64_t ret_ref = 0;
37290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37291         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37292         return ret_ref;
37293 }
37294
37295 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37296         LDKUpdateFailMalformedHTLC a_conv;
37297         a_conv.inner = untag_ptr(a);
37298         a_conv.is_owned = ptr_is_owned(a);
37299         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37300         a_conv.is_owned = false;
37301         LDKUpdateFailMalformedHTLC b_conv;
37302         b_conv.inner = untag_ptr(b);
37303         b_conv.is_owned = ptr_is_owned(b);
37304         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37305         b_conv.is_owned = false;
37306         jboolean ret_conv = UpdateFailMalformedHTLC_eq(&a_conv, &b_conv);
37307         return ret_conv;
37308 }
37309
37310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37311         LDKCommitmentSigned this_obj_conv;
37312         this_obj_conv.inner = untag_ptr(this_obj);
37313         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37315         CommitmentSigned_free(this_obj_conv);
37316 }
37317
37318 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37319         LDKCommitmentSigned this_ptr_conv;
37320         this_ptr_conv.inner = untag_ptr(this_ptr);
37321         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37323         this_ptr_conv.is_owned = false;
37324         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37325         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
37326         return ret_arr;
37327 }
37328
37329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37330         LDKCommitmentSigned this_ptr_conv;
37331         this_ptr_conv.inner = untag_ptr(this_ptr);
37332         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37334         this_ptr_conv.is_owned = false;
37335         LDKThirtyTwoBytes val_ref;
37336         CHECK((*env)->GetArrayLength(env, val) == 32);
37337         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37338         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
37339 }
37340
37341 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
37342         LDKCommitmentSigned this_ptr_conv;
37343         this_ptr_conv.inner = untag_ptr(this_ptr);
37344         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37346         this_ptr_conv.is_owned = false;
37347         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37348         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
37349         return ret_arr;
37350 }
37351
37352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37353         LDKCommitmentSigned this_ptr_conv;
37354         this_ptr_conv.inner = untag_ptr(this_ptr);
37355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37357         this_ptr_conv.is_owned = false;
37358         LDKSignature val_ref;
37359         CHECK((*env)->GetArrayLength(env, val) == 64);
37360         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37361         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
37362 }
37363
37364 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr) {
37365         LDKCommitmentSigned this_ptr_conv;
37366         this_ptr_conv.inner = untag_ptr(this_ptr);
37367         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37369         this_ptr_conv.is_owned = false;
37370         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
37371         jobjectArray ret_arr = NULL;
37372         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
37373         ;
37374         for (size_t i = 0; i < ret_var.datalen; i++) {
37375                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
37376                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
37377                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
37378         }
37379         
37380         FREE(ret_var.data);
37381         return ret_arr;
37382 }
37383
37384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
37385         LDKCommitmentSigned this_ptr_conv;
37386         this_ptr_conv.inner = untag_ptr(this_ptr);
37387         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37389         this_ptr_conv.is_owned = false;
37390         LDKCVec_SignatureZ val_constr;
37391         val_constr.datalen = (*env)->GetArrayLength(env, val);
37392         if (val_constr.datalen > 0)
37393                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
37394         else
37395                 val_constr.data = NULL;
37396         for (size_t i = 0; i < val_constr.datalen; i++) {
37397                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
37398                 LDKSignature val_conv_8_ref;
37399                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
37400                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
37401                 val_constr.data[i] = val_conv_8_ref;
37402         }
37403         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
37404 }
37405
37406 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) {
37407         LDKThirtyTwoBytes channel_id_arg_ref;
37408         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37409         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37410         LDKSignature signature_arg_ref;
37411         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
37412         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
37413         LDKCVec_SignatureZ htlc_signatures_arg_constr;
37414         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
37415         if (htlc_signatures_arg_constr.datalen > 0)
37416                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
37417         else
37418                 htlc_signatures_arg_constr.data = NULL;
37419         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
37420                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
37421                 LDKSignature htlc_signatures_arg_conv_8_ref;
37422                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
37423                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
37424                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
37425         }
37426         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
37427         int64_t ret_ref = 0;
37428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37429         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37430         return ret_ref;
37431 }
37432
37433 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
37434         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
37435         int64_t ret_ref = 0;
37436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37437         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37438         return ret_ref;
37439 }
37440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37441         LDKCommitmentSigned arg_conv;
37442         arg_conv.inner = untag_ptr(arg);
37443         arg_conv.is_owned = ptr_is_owned(arg);
37444         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37445         arg_conv.is_owned = false;
37446         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
37447         return ret_conv;
37448 }
37449
37450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37451         LDKCommitmentSigned orig_conv;
37452         orig_conv.inner = untag_ptr(orig);
37453         orig_conv.is_owned = ptr_is_owned(orig);
37454         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37455         orig_conv.is_owned = false;
37456         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
37457         int64_t ret_ref = 0;
37458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37459         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37460         return ret_ref;
37461 }
37462
37463 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37464         LDKCommitmentSigned a_conv;
37465         a_conv.inner = untag_ptr(a);
37466         a_conv.is_owned = ptr_is_owned(a);
37467         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37468         a_conv.is_owned = false;
37469         LDKCommitmentSigned b_conv;
37470         b_conv.inner = untag_ptr(b);
37471         b_conv.is_owned = ptr_is_owned(b);
37472         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37473         b_conv.is_owned = false;
37474         jboolean ret_conv = CommitmentSigned_eq(&a_conv, &b_conv);
37475         return ret_conv;
37476 }
37477
37478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37479         LDKRevokeAndACK this_obj_conv;
37480         this_obj_conv.inner = untag_ptr(this_obj);
37481         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37483         RevokeAndACK_free(this_obj_conv);
37484 }
37485
37486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37487         LDKRevokeAndACK this_ptr_conv;
37488         this_ptr_conv.inner = untag_ptr(this_ptr);
37489         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37491         this_ptr_conv.is_owned = false;
37492         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37493         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
37494         return ret_arr;
37495 }
37496
37497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37498         LDKRevokeAndACK this_ptr_conv;
37499         this_ptr_conv.inner = untag_ptr(this_ptr);
37500         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37502         this_ptr_conv.is_owned = false;
37503         LDKThirtyTwoBytes val_ref;
37504         CHECK((*env)->GetArrayLength(env, val) == 32);
37505         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37506         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
37507 }
37508
37509 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
37510         LDKRevokeAndACK this_ptr_conv;
37511         this_ptr_conv.inner = untag_ptr(this_ptr);
37512         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37514         this_ptr_conv.is_owned = false;
37515         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37516         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
37517         return ret_arr;
37518 }
37519
37520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37521         LDKRevokeAndACK this_ptr_conv;
37522         this_ptr_conv.inner = untag_ptr(this_ptr);
37523         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37525         this_ptr_conv.is_owned = false;
37526         LDKThirtyTwoBytes val_ref;
37527         CHECK((*env)->GetArrayLength(env, val) == 32);
37528         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37529         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
37530 }
37531
37532 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37533         LDKRevokeAndACK this_ptr_conv;
37534         this_ptr_conv.inner = untag_ptr(this_ptr);
37535         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37537         this_ptr_conv.is_owned = false;
37538         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37539         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
37540         return ret_arr;
37541 }
37542
37543 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) {
37544         LDKRevokeAndACK this_ptr_conv;
37545         this_ptr_conv.inner = untag_ptr(this_ptr);
37546         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37548         this_ptr_conv.is_owned = false;
37549         LDKPublicKey val_ref;
37550         CHECK((*env)->GetArrayLength(env, val) == 33);
37551         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37552         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
37553 }
37554
37555 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) {
37556         LDKThirtyTwoBytes channel_id_arg_ref;
37557         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37558         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37559         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
37560         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
37561         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
37562         LDKPublicKey next_per_commitment_point_arg_ref;
37563         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
37564         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
37565         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
37566         int64_t ret_ref = 0;
37567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37568         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37569         return ret_ref;
37570 }
37571
37572 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
37573         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
37574         int64_t ret_ref = 0;
37575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37576         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37577         return ret_ref;
37578 }
37579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37580         LDKRevokeAndACK arg_conv;
37581         arg_conv.inner = untag_ptr(arg);
37582         arg_conv.is_owned = ptr_is_owned(arg);
37583         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37584         arg_conv.is_owned = false;
37585         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
37586         return ret_conv;
37587 }
37588
37589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37590         LDKRevokeAndACK orig_conv;
37591         orig_conv.inner = untag_ptr(orig);
37592         orig_conv.is_owned = ptr_is_owned(orig);
37593         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37594         orig_conv.is_owned = false;
37595         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
37596         int64_t ret_ref = 0;
37597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37598         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37599         return ret_ref;
37600 }
37601
37602 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37603         LDKRevokeAndACK a_conv;
37604         a_conv.inner = untag_ptr(a);
37605         a_conv.is_owned = ptr_is_owned(a);
37606         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37607         a_conv.is_owned = false;
37608         LDKRevokeAndACK b_conv;
37609         b_conv.inner = untag_ptr(b);
37610         b_conv.is_owned = ptr_is_owned(b);
37611         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37612         b_conv.is_owned = false;
37613         jboolean ret_conv = RevokeAndACK_eq(&a_conv, &b_conv);
37614         return ret_conv;
37615 }
37616
37617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37618         LDKUpdateFee this_obj_conv;
37619         this_obj_conv.inner = untag_ptr(this_obj);
37620         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37622         UpdateFee_free(this_obj_conv);
37623 }
37624
37625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37626         LDKUpdateFee this_ptr_conv;
37627         this_ptr_conv.inner = untag_ptr(this_ptr);
37628         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37630         this_ptr_conv.is_owned = false;
37631         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37632         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
37633         return ret_arr;
37634 }
37635
37636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37637         LDKUpdateFee this_ptr_conv;
37638         this_ptr_conv.inner = untag_ptr(this_ptr);
37639         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37641         this_ptr_conv.is_owned = false;
37642         LDKThirtyTwoBytes val_ref;
37643         CHECK((*env)->GetArrayLength(env, val) == 32);
37644         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37645         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
37646 }
37647
37648 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
37649         LDKUpdateFee this_ptr_conv;
37650         this_ptr_conv.inner = untag_ptr(this_ptr);
37651         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37653         this_ptr_conv.is_owned = false;
37654         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
37655         return ret_conv;
37656 }
37657
37658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37659         LDKUpdateFee this_ptr_conv;
37660         this_ptr_conv.inner = untag_ptr(this_ptr);
37661         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37663         this_ptr_conv.is_owned = false;
37664         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
37665 }
37666
37667 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) {
37668         LDKThirtyTwoBytes channel_id_arg_ref;
37669         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37670         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37671         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
37672         int64_t ret_ref = 0;
37673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37674         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37675         return ret_ref;
37676 }
37677
37678 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
37679         LDKUpdateFee ret_var = UpdateFee_clone(arg);
37680         int64_t ret_ref = 0;
37681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37682         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37683         return ret_ref;
37684 }
37685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37686         LDKUpdateFee arg_conv;
37687         arg_conv.inner = untag_ptr(arg);
37688         arg_conv.is_owned = ptr_is_owned(arg);
37689         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37690         arg_conv.is_owned = false;
37691         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
37692         return ret_conv;
37693 }
37694
37695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37696         LDKUpdateFee orig_conv;
37697         orig_conv.inner = untag_ptr(orig);
37698         orig_conv.is_owned = ptr_is_owned(orig);
37699         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37700         orig_conv.is_owned = false;
37701         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
37702         int64_t ret_ref = 0;
37703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37704         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37705         return ret_ref;
37706 }
37707
37708 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37709         LDKUpdateFee a_conv;
37710         a_conv.inner = untag_ptr(a);
37711         a_conv.is_owned = ptr_is_owned(a);
37712         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37713         a_conv.is_owned = false;
37714         LDKUpdateFee b_conv;
37715         b_conv.inner = untag_ptr(b);
37716         b_conv.is_owned = ptr_is_owned(b);
37717         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37718         b_conv.is_owned = false;
37719         jboolean ret_conv = UpdateFee_eq(&a_conv, &b_conv);
37720         return ret_conv;
37721 }
37722
37723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37724         LDKDataLossProtect this_obj_conv;
37725         this_obj_conv.inner = untag_ptr(this_obj);
37726         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37728         DataLossProtect_free(this_obj_conv);
37729 }
37730
37731 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
37732         LDKDataLossProtect this_ptr_conv;
37733         this_ptr_conv.inner = untag_ptr(this_ptr);
37734         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37736         this_ptr_conv.is_owned = false;
37737         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37738         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
37739         return ret_arr;
37740 }
37741
37742 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) {
37743         LDKDataLossProtect this_ptr_conv;
37744         this_ptr_conv.inner = untag_ptr(this_ptr);
37745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37747         this_ptr_conv.is_owned = false;
37748         LDKThirtyTwoBytes val_ref;
37749         CHECK((*env)->GetArrayLength(env, val) == 32);
37750         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37751         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
37752 }
37753
37754 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37755         LDKDataLossProtect this_ptr_conv;
37756         this_ptr_conv.inner = untag_ptr(this_ptr);
37757         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37759         this_ptr_conv.is_owned = false;
37760         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37761         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
37762         return ret_arr;
37763 }
37764
37765 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) {
37766         LDKDataLossProtect this_ptr_conv;
37767         this_ptr_conv.inner = untag_ptr(this_ptr);
37768         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37770         this_ptr_conv.is_owned = false;
37771         LDKPublicKey val_ref;
37772         CHECK((*env)->GetArrayLength(env, val) == 33);
37773         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37774         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
37775 }
37776
37777 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) {
37778         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
37779         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
37780         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
37781         LDKPublicKey my_current_per_commitment_point_arg_ref;
37782         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
37783         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
37784         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
37785         int64_t ret_ref = 0;
37786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37787         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37788         return ret_ref;
37789 }
37790
37791 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
37792         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
37793         int64_t ret_ref = 0;
37794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37795         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37796         return ret_ref;
37797 }
37798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37799         LDKDataLossProtect arg_conv;
37800         arg_conv.inner = untag_ptr(arg);
37801         arg_conv.is_owned = ptr_is_owned(arg);
37802         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37803         arg_conv.is_owned = false;
37804         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
37805         return ret_conv;
37806 }
37807
37808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37809         LDKDataLossProtect orig_conv;
37810         orig_conv.inner = untag_ptr(orig);
37811         orig_conv.is_owned = ptr_is_owned(orig);
37812         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37813         orig_conv.is_owned = false;
37814         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
37815         int64_t ret_ref = 0;
37816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37817         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37818         return ret_ref;
37819 }
37820
37821 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37822         LDKDataLossProtect a_conv;
37823         a_conv.inner = untag_ptr(a);
37824         a_conv.is_owned = ptr_is_owned(a);
37825         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37826         a_conv.is_owned = false;
37827         LDKDataLossProtect b_conv;
37828         b_conv.inner = untag_ptr(b);
37829         b_conv.is_owned = ptr_is_owned(b);
37830         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37831         b_conv.is_owned = false;
37832         jboolean ret_conv = DataLossProtect_eq(&a_conv, &b_conv);
37833         return ret_conv;
37834 }
37835
37836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37837         LDKChannelReestablish this_obj_conv;
37838         this_obj_conv.inner = untag_ptr(this_obj);
37839         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37841         ChannelReestablish_free(this_obj_conv);
37842 }
37843
37844 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37845         LDKChannelReestablish this_ptr_conv;
37846         this_ptr_conv.inner = untag_ptr(this_ptr);
37847         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37849         this_ptr_conv.is_owned = false;
37850         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37851         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
37852         return ret_arr;
37853 }
37854
37855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37856         LDKChannelReestablish this_ptr_conv;
37857         this_ptr_conv.inner = untag_ptr(this_ptr);
37858         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37860         this_ptr_conv.is_owned = false;
37861         LDKThirtyTwoBytes val_ref;
37862         CHECK((*env)->GetArrayLength(env, val) == 32);
37863         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37864         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
37865 }
37866
37867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
37868         LDKChannelReestablish this_ptr_conv;
37869         this_ptr_conv.inner = untag_ptr(this_ptr);
37870         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37872         this_ptr_conv.is_owned = false;
37873         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
37874         return ret_conv;
37875 }
37876
37877 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) {
37878         LDKChannelReestablish this_ptr_conv;
37879         this_ptr_conv.inner = untag_ptr(this_ptr);
37880         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37882         this_ptr_conv.is_owned = false;
37883         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
37884 }
37885
37886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
37887         LDKChannelReestablish this_ptr_conv;
37888         this_ptr_conv.inner = untag_ptr(this_ptr);
37889         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37891         this_ptr_conv.is_owned = false;
37892         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
37893         return ret_conv;
37894 }
37895
37896 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) {
37897         LDKChannelReestablish this_ptr_conv;
37898         this_ptr_conv.inner = untag_ptr(this_ptr);
37899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37901         this_ptr_conv.is_owned = false;
37902         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
37903 }
37904
37905 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
37906         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
37907         int64_t ret_ref = 0;
37908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37910         return ret_ref;
37911 }
37912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37913         LDKChannelReestablish arg_conv;
37914         arg_conv.inner = untag_ptr(arg);
37915         arg_conv.is_owned = ptr_is_owned(arg);
37916         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37917         arg_conv.is_owned = false;
37918         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
37919         return ret_conv;
37920 }
37921
37922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37923         LDKChannelReestablish orig_conv;
37924         orig_conv.inner = untag_ptr(orig);
37925         orig_conv.is_owned = ptr_is_owned(orig);
37926         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37927         orig_conv.is_owned = false;
37928         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
37929         int64_t ret_ref = 0;
37930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37931         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37932         return ret_ref;
37933 }
37934
37935 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37936         LDKChannelReestablish a_conv;
37937         a_conv.inner = untag_ptr(a);
37938         a_conv.is_owned = ptr_is_owned(a);
37939         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37940         a_conv.is_owned = false;
37941         LDKChannelReestablish b_conv;
37942         b_conv.inner = untag_ptr(b);
37943         b_conv.is_owned = ptr_is_owned(b);
37944         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37945         b_conv.is_owned = false;
37946         jboolean ret_conv = ChannelReestablish_eq(&a_conv, &b_conv);
37947         return ret_conv;
37948 }
37949
37950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37951         LDKAnnouncementSignatures this_obj_conv;
37952         this_obj_conv.inner = untag_ptr(this_obj);
37953         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37955         AnnouncementSignatures_free(this_obj_conv);
37956 }
37957
37958 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37959         LDKAnnouncementSignatures this_ptr_conv;
37960         this_ptr_conv.inner = untag_ptr(this_ptr);
37961         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37963         this_ptr_conv.is_owned = false;
37964         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37965         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
37966         return ret_arr;
37967 }
37968
37969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37970         LDKAnnouncementSignatures this_ptr_conv;
37971         this_ptr_conv.inner = untag_ptr(this_ptr);
37972         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37974         this_ptr_conv.is_owned = false;
37975         LDKThirtyTwoBytes val_ref;
37976         CHECK((*env)->GetArrayLength(env, val) == 32);
37977         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37978         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
37979 }
37980
37981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37982         LDKAnnouncementSignatures this_ptr_conv;
37983         this_ptr_conv.inner = untag_ptr(this_ptr);
37984         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37986         this_ptr_conv.is_owned = false;
37987         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
37988         return ret_conv;
37989 }
37990
37991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37992         LDKAnnouncementSignatures this_ptr_conv;
37993         this_ptr_conv.inner = untag_ptr(this_ptr);
37994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37996         this_ptr_conv.is_owned = false;
37997         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
37998 }
37999
38000 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38001         LDKAnnouncementSignatures this_ptr_conv;
38002         this_ptr_conv.inner = untag_ptr(this_ptr);
38003         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38005         this_ptr_conv.is_owned = false;
38006         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38007         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
38008         return ret_arr;
38009 }
38010
38011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38012         LDKAnnouncementSignatures this_ptr_conv;
38013         this_ptr_conv.inner = untag_ptr(this_ptr);
38014         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38016         this_ptr_conv.is_owned = false;
38017         LDKSignature val_ref;
38018         CHECK((*env)->GetArrayLength(env, val) == 64);
38019         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38020         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
38021 }
38022
38023 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38024         LDKAnnouncementSignatures this_ptr_conv;
38025         this_ptr_conv.inner = untag_ptr(this_ptr);
38026         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38028         this_ptr_conv.is_owned = false;
38029         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38030         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
38031         return ret_arr;
38032 }
38033
38034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38035         LDKAnnouncementSignatures this_ptr_conv;
38036         this_ptr_conv.inner = untag_ptr(this_ptr);
38037         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38039         this_ptr_conv.is_owned = false;
38040         LDKSignature val_ref;
38041         CHECK((*env)->GetArrayLength(env, val) == 64);
38042         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38043         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
38044 }
38045
38046 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) {
38047         LDKThirtyTwoBytes channel_id_arg_ref;
38048         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
38049         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
38050         LDKSignature node_signature_arg_ref;
38051         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
38052         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
38053         LDKSignature bitcoin_signature_arg_ref;
38054         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
38055         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
38056         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
38057         int64_t ret_ref = 0;
38058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38059         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38060         return ret_ref;
38061 }
38062
38063 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
38064         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
38065         int64_t ret_ref = 0;
38066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38067         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38068         return ret_ref;
38069 }
38070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38071         LDKAnnouncementSignatures arg_conv;
38072         arg_conv.inner = untag_ptr(arg);
38073         arg_conv.is_owned = ptr_is_owned(arg);
38074         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38075         arg_conv.is_owned = false;
38076         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
38077         return ret_conv;
38078 }
38079
38080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38081         LDKAnnouncementSignatures orig_conv;
38082         orig_conv.inner = untag_ptr(orig);
38083         orig_conv.is_owned = ptr_is_owned(orig);
38084         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38085         orig_conv.is_owned = false;
38086         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
38087         int64_t ret_ref = 0;
38088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38089         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38090         return ret_ref;
38091 }
38092
38093 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38094         LDKAnnouncementSignatures a_conv;
38095         a_conv.inner = untag_ptr(a);
38096         a_conv.is_owned = ptr_is_owned(a);
38097         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38098         a_conv.is_owned = false;
38099         LDKAnnouncementSignatures b_conv;
38100         b_conv.inner = untag_ptr(b);
38101         b_conv.is_owned = ptr_is_owned(b);
38102         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38103         b_conv.is_owned = false;
38104         jboolean ret_conv = AnnouncementSignatures_eq(&a_conv, &b_conv);
38105         return ret_conv;
38106 }
38107
38108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38109         if (!ptr_is_owned(this_ptr)) return;
38110         void* this_ptr_ptr = untag_ptr(this_ptr);
38111         CHECK_ACCESS(this_ptr_ptr);
38112         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
38113         FREE(untag_ptr(this_ptr));
38114         NetAddress_free(this_ptr_conv);
38115 }
38116
38117 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
38118         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38119         *ret_copy = NetAddress_clone(arg);
38120         int64_t ret_ref = tag_ptr(ret_copy, true);
38121         return ret_ref;
38122 }
38123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38124         LDKNetAddress* arg_conv = (LDKNetAddress*)untag_ptr(arg);
38125         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
38126         return ret_conv;
38127 }
38128
38129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38130         LDKNetAddress* orig_conv = (LDKNetAddress*)untag_ptr(orig);
38131         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38132         *ret_copy = NetAddress_clone(orig_conv);
38133         int64_t ret_ref = tag_ptr(ret_copy, true);
38134         return ret_ref;
38135 }
38136
38137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
38138         LDKFourBytes addr_ref;
38139         CHECK((*env)->GetArrayLength(env, addr) == 4);
38140         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
38141         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38142         *ret_copy = NetAddress_ipv4(addr_ref, port);
38143         int64_t ret_ref = tag_ptr(ret_copy, true);
38144         return ret_ref;
38145 }
38146
38147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
38148         LDKSixteenBytes addr_ref;
38149         CHECK((*env)->GetArrayLength(env, addr) == 16);
38150         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
38151         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38152         *ret_copy = NetAddress_ipv6(addr_ref, port);
38153         int64_t ret_ref = tag_ptr(ret_copy, true);
38154         return ret_ref;
38155 }
38156
38157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
38158         LDKTwelveBytes a_ref;
38159         CHECK((*env)->GetArrayLength(env, a) == 12);
38160         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
38161         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38162         *ret_copy = NetAddress_onion_v2(a_ref);
38163         int64_t ret_ref = tag_ptr(ret_copy, true);
38164         return ret_ref;
38165 }
38166
38167 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) {
38168         LDKThirtyTwoBytes ed25519_pubkey_ref;
38169         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
38170         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
38171         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38172         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
38173         int64_t ret_ref = tag_ptr(ret_copy, true);
38174         return ret_ref;
38175 }
38176
38177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1hostname(JNIEnv *env, jclass clz, int64_t hostname, int16_t port) {
38178         LDKHostname hostname_conv;
38179         hostname_conv.inner = untag_ptr(hostname);
38180         hostname_conv.is_owned = ptr_is_owned(hostname);
38181         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
38182         hostname_conv = Hostname_clone(&hostname_conv);
38183         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38184         *ret_copy = NetAddress_hostname(hostname_conv, port);
38185         int64_t ret_ref = tag_ptr(ret_copy, true);
38186         return ret_ref;
38187 }
38188
38189 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetAddress_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38190         LDKNetAddress* a_conv = (LDKNetAddress*)untag_ptr(a);
38191         LDKNetAddress* b_conv = (LDKNetAddress*)untag_ptr(b);
38192         jboolean ret_conv = NetAddress_eq(a_conv, b_conv);
38193         return ret_conv;
38194 }
38195
38196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
38197         LDKNetAddress* obj_conv = (LDKNetAddress*)untag_ptr(obj);
38198         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
38199         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38200         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38201         CVec_u8Z_free(ret_var);
38202         return ret_arr;
38203 }
38204
38205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38206         LDKu8slice ser_ref;
38207         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38208         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38209         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
38210         *ret_conv = NetAddress_read(ser_ref);
38211         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38212         return tag_ptr(ret_conv, true);
38213 }
38214
38215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38216         if (!ptr_is_owned(this_ptr)) return;
38217         void* this_ptr_ptr = untag_ptr(this_ptr);
38218         CHECK_ACCESS(this_ptr_ptr);
38219         LDKUnsignedGossipMessage this_ptr_conv = *(LDKUnsignedGossipMessage*)(this_ptr_ptr);
38220         FREE(untag_ptr(this_ptr));
38221         UnsignedGossipMessage_free(this_ptr_conv);
38222 }
38223
38224 static inline uint64_t UnsignedGossipMessage_clone_ptr(LDKUnsignedGossipMessage *NONNULL_PTR arg) {
38225         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38226         *ret_copy = UnsignedGossipMessage_clone(arg);
38227         int64_t ret_ref = tag_ptr(ret_copy, true);
38228         return ret_ref;
38229 }
38230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38231         LDKUnsignedGossipMessage* arg_conv = (LDKUnsignedGossipMessage*)untag_ptr(arg);
38232         int64_t ret_conv = UnsignedGossipMessage_clone_ptr(arg_conv);
38233         return ret_conv;
38234 }
38235
38236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38237         LDKUnsignedGossipMessage* orig_conv = (LDKUnsignedGossipMessage*)untag_ptr(orig);
38238         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38239         *ret_copy = UnsignedGossipMessage_clone(orig_conv);
38240         int64_t ret_ref = tag_ptr(ret_copy, true);
38241         return ret_ref;
38242 }
38243
38244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1channel_1announcement(JNIEnv *env, jclass clz, int64_t a) {
38245         LDKUnsignedChannelAnnouncement a_conv;
38246         a_conv.inner = untag_ptr(a);
38247         a_conv.is_owned = ptr_is_owned(a);
38248         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38249         a_conv = UnsignedChannelAnnouncement_clone(&a_conv);
38250         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38251         *ret_copy = UnsignedGossipMessage_channel_announcement(a_conv);
38252         int64_t ret_ref = tag_ptr(ret_copy, true);
38253         return ret_ref;
38254 }
38255
38256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1channel_1update(JNIEnv *env, jclass clz, int64_t a) {
38257         LDKUnsignedChannelUpdate a_conv;
38258         a_conv.inner = untag_ptr(a);
38259         a_conv.is_owned = ptr_is_owned(a);
38260         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38261         a_conv = UnsignedChannelUpdate_clone(&a_conv);
38262         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38263         *ret_copy = UnsignedGossipMessage_channel_update(a_conv);
38264         int64_t ret_ref = tag_ptr(ret_copy, true);
38265         return ret_ref;
38266 }
38267
38268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1node_1announcement(JNIEnv *env, jclass clz, int64_t a) {
38269         LDKUnsignedNodeAnnouncement a_conv;
38270         a_conv.inner = untag_ptr(a);
38271         a_conv.is_owned = ptr_is_owned(a);
38272         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38273         a_conv = UnsignedNodeAnnouncement_clone(&a_conv);
38274         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38275         *ret_copy = UnsignedGossipMessage_node_announcement(a_conv);
38276         int64_t ret_ref = tag_ptr(ret_copy, true);
38277         return ret_ref;
38278 }
38279
38280 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
38281         LDKUnsignedGossipMessage* obj_conv = (LDKUnsignedGossipMessage*)untag_ptr(obj);
38282         LDKCVec_u8Z ret_var = UnsignedGossipMessage_write(obj_conv);
38283         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38284         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38285         CVec_u8Z_free(ret_var);
38286         return ret_arr;
38287 }
38288
38289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38290         LDKUnsignedNodeAnnouncement this_obj_conv;
38291         this_obj_conv.inner = untag_ptr(this_obj);
38292         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38294         UnsignedNodeAnnouncement_free(this_obj_conv);
38295 }
38296
38297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
38298         LDKUnsignedNodeAnnouncement this_ptr_conv;
38299         this_ptr_conv.inner = untag_ptr(this_ptr);
38300         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38302         this_ptr_conv.is_owned = false;
38303         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
38304         int64_t ret_ref = 0;
38305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38306         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38307         return ret_ref;
38308 }
38309
38310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38311         LDKUnsignedNodeAnnouncement this_ptr_conv;
38312         this_ptr_conv.inner = untag_ptr(this_ptr);
38313         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38315         this_ptr_conv.is_owned = false;
38316         LDKNodeFeatures val_conv;
38317         val_conv.inner = untag_ptr(val);
38318         val_conv.is_owned = ptr_is_owned(val);
38319         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38320         val_conv = NodeFeatures_clone(&val_conv);
38321         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
38322 }
38323
38324 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
38325         LDKUnsignedNodeAnnouncement this_ptr_conv;
38326         this_ptr_conv.inner = untag_ptr(this_ptr);
38327         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38329         this_ptr_conv.is_owned = false;
38330         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
38331         return ret_conv;
38332 }
38333
38334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38335         LDKUnsignedNodeAnnouncement this_ptr_conv;
38336         this_ptr_conv.inner = untag_ptr(this_ptr);
38337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38339         this_ptr_conv.is_owned = false;
38340         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
38341 }
38342
38343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38344         LDKUnsignedNodeAnnouncement this_ptr_conv;
38345         this_ptr_conv.inner = untag_ptr(this_ptr);
38346         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38348         this_ptr_conv.is_owned = false;
38349         LDKNodeId ret_var = UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv);
38350         int64_t ret_ref = 0;
38351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38352         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38353         return ret_ref;
38354 }
38355
38356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
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         LDKNodeId val_conv;
38363         val_conv.inner = untag_ptr(val);
38364         val_conv.is_owned = ptr_is_owned(val);
38365         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38366         val_conv = NodeId_clone(&val_conv);
38367         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_conv);
38368 }
38369
38370 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
38371         LDKUnsignedNodeAnnouncement this_ptr_conv;
38372         this_ptr_conv.inner = untag_ptr(this_ptr);
38373         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38375         this_ptr_conv.is_owned = false;
38376         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
38377         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
38378         return ret_arr;
38379 }
38380
38381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38382         LDKUnsignedNodeAnnouncement this_ptr_conv;
38383         this_ptr_conv.inner = untag_ptr(this_ptr);
38384         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38386         this_ptr_conv.is_owned = false;
38387         LDKThreeBytes val_ref;
38388         CHECK((*env)->GetArrayLength(env, val) == 3);
38389         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
38390         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
38391 }
38392
38393 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38400         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
38401         return ret_arr;
38402 }
38403
38404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38405         LDKUnsignedNodeAnnouncement this_ptr_conv;
38406         this_ptr_conv.inner = untag_ptr(this_ptr);
38407         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38409         this_ptr_conv.is_owned = false;
38410         LDKThirtyTwoBytes val_ref;
38411         CHECK((*env)->GetArrayLength(env, val) == 32);
38412         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38413         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
38414 }
38415
38416 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
38417         LDKUnsignedNodeAnnouncement this_ptr_conv;
38418         this_ptr_conv.inner = untag_ptr(this_ptr);
38419         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38421         this_ptr_conv.is_owned = false;
38422         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
38423         int64_tArray ret_arr = NULL;
38424         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38425         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38426         for (size_t m = 0; m < ret_var.datalen; m++) {
38427                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38428                 *ret_conv_12_copy = ret_var.data[m];
38429                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
38430                 ret_arr_ptr[m] = ret_conv_12_ref;
38431         }
38432         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38433         FREE(ret_var.data);
38434         return ret_arr;
38435 }
38436
38437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38438         LDKUnsignedNodeAnnouncement this_ptr_conv;
38439         this_ptr_conv.inner = untag_ptr(this_ptr);
38440         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38442         this_ptr_conv.is_owned = false;
38443         LDKCVec_NetAddressZ val_constr;
38444         val_constr.datalen = (*env)->GetArrayLength(env, val);
38445         if (val_constr.datalen > 0)
38446                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
38447         else
38448                 val_constr.data = NULL;
38449         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38450         for (size_t m = 0; m < val_constr.datalen; m++) {
38451                 int64_t val_conv_12 = val_vals[m];
38452                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
38453                 CHECK_ACCESS(val_conv_12_ptr);
38454                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
38455                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
38456                 val_constr.data[m] = val_conv_12_conv;
38457         }
38458         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38459         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
38460 }
38461
38462 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
38463         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
38464         int64_t ret_ref = 0;
38465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38466         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38467         return ret_ref;
38468 }
38469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38470         LDKUnsignedNodeAnnouncement arg_conv;
38471         arg_conv.inner = untag_ptr(arg);
38472         arg_conv.is_owned = ptr_is_owned(arg);
38473         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38474         arg_conv.is_owned = false;
38475         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
38476         return ret_conv;
38477 }
38478
38479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38480         LDKUnsignedNodeAnnouncement orig_conv;
38481         orig_conv.inner = untag_ptr(orig);
38482         orig_conv.is_owned = ptr_is_owned(orig);
38483         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38484         orig_conv.is_owned = false;
38485         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
38486         int64_t ret_ref = 0;
38487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38488         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38489         return ret_ref;
38490 }
38491
38492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38493         LDKUnsignedNodeAnnouncement a_conv;
38494         a_conv.inner = untag_ptr(a);
38495         a_conv.is_owned = ptr_is_owned(a);
38496         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38497         a_conv.is_owned = false;
38498         LDKUnsignedNodeAnnouncement b_conv;
38499         b_conv.inner = untag_ptr(b);
38500         b_conv.is_owned = ptr_is_owned(b);
38501         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38502         b_conv.is_owned = false;
38503         jboolean ret_conv = UnsignedNodeAnnouncement_eq(&a_conv, &b_conv);
38504         return ret_conv;
38505 }
38506
38507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38508         LDKNodeAnnouncement this_obj_conv;
38509         this_obj_conv.inner = untag_ptr(this_obj);
38510         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38512         NodeAnnouncement_free(this_obj_conv);
38513 }
38514
38515 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38516         LDKNodeAnnouncement this_ptr_conv;
38517         this_ptr_conv.inner = untag_ptr(this_ptr);
38518         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38520         this_ptr_conv.is_owned = false;
38521         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38522         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
38523         return ret_arr;
38524 }
38525
38526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38527         LDKNodeAnnouncement this_ptr_conv;
38528         this_ptr_conv.inner = untag_ptr(this_ptr);
38529         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38531         this_ptr_conv.is_owned = false;
38532         LDKSignature val_ref;
38533         CHECK((*env)->GetArrayLength(env, val) == 64);
38534         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38535         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
38536 }
38537
38538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
38539         LDKNodeAnnouncement this_ptr_conv;
38540         this_ptr_conv.inner = untag_ptr(this_ptr);
38541         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38543         this_ptr_conv.is_owned = false;
38544         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
38545         int64_t ret_ref = 0;
38546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38547         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38548         return ret_ref;
38549 }
38550
38551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38552         LDKNodeAnnouncement this_ptr_conv;
38553         this_ptr_conv.inner = untag_ptr(this_ptr);
38554         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38556         this_ptr_conv.is_owned = false;
38557         LDKUnsignedNodeAnnouncement val_conv;
38558         val_conv.inner = untag_ptr(val);
38559         val_conv.is_owned = ptr_is_owned(val);
38560         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38561         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
38562         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
38563 }
38564
38565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
38566         LDKSignature signature_arg_ref;
38567         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
38568         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
38569         LDKUnsignedNodeAnnouncement contents_arg_conv;
38570         contents_arg_conv.inner = untag_ptr(contents_arg);
38571         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
38572         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
38573         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
38574         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
38575         int64_t ret_ref = 0;
38576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38577         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38578         return ret_ref;
38579 }
38580
38581 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
38582         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
38583         int64_t ret_ref = 0;
38584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38585         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38586         return ret_ref;
38587 }
38588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38589         LDKNodeAnnouncement arg_conv;
38590         arg_conv.inner = untag_ptr(arg);
38591         arg_conv.is_owned = ptr_is_owned(arg);
38592         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38593         arg_conv.is_owned = false;
38594         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
38595         return ret_conv;
38596 }
38597
38598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38599         LDKNodeAnnouncement orig_conv;
38600         orig_conv.inner = untag_ptr(orig);
38601         orig_conv.is_owned = ptr_is_owned(orig);
38602         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38603         orig_conv.is_owned = false;
38604         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
38605         int64_t ret_ref = 0;
38606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38607         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38608         return ret_ref;
38609 }
38610
38611 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38612         LDKNodeAnnouncement a_conv;
38613         a_conv.inner = untag_ptr(a);
38614         a_conv.is_owned = ptr_is_owned(a);
38615         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38616         a_conv.is_owned = false;
38617         LDKNodeAnnouncement b_conv;
38618         b_conv.inner = untag_ptr(b);
38619         b_conv.is_owned = ptr_is_owned(b);
38620         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38621         b_conv.is_owned = false;
38622         jboolean ret_conv = NodeAnnouncement_eq(&a_conv, &b_conv);
38623         return ret_conv;
38624 }
38625
38626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38627         LDKUnsignedChannelAnnouncement this_obj_conv;
38628         this_obj_conv.inner = untag_ptr(this_obj);
38629         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38631         UnsignedChannelAnnouncement_free(this_obj_conv);
38632 }
38633
38634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
38635         LDKUnsignedChannelAnnouncement this_ptr_conv;
38636         this_ptr_conv.inner = untag_ptr(this_ptr);
38637         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38639         this_ptr_conv.is_owned = false;
38640         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
38641         int64_t ret_ref = 0;
38642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38643         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38644         return ret_ref;
38645 }
38646
38647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38648         LDKUnsignedChannelAnnouncement this_ptr_conv;
38649         this_ptr_conv.inner = untag_ptr(this_ptr);
38650         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38652         this_ptr_conv.is_owned = false;
38653         LDKChannelFeatures val_conv;
38654         val_conv.inner = untag_ptr(val);
38655         val_conv.is_owned = ptr_is_owned(val);
38656         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38657         val_conv = ChannelFeatures_clone(&val_conv);
38658         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
38659 }
38660
38661 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38662         LDKUnsignedChannelAnnouncement this_ptr_conv;
38663         this_ptr_conv.inner = untag_ptr(this_ptr);
38664         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38666         this_ptr_conv.is_owned = false;
38667         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38668         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
38669         return ret_arr;
38670 }
38671
38672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38673         LDKUnsignedChannelAnnouncement this_ptr_conv;
38674         this_ptr_conv.inner = untag_ptr(this_ptr);
38675         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38677         this_ptr_conv.is_owned = false;
38678         LDKThirtyTwoBytes val_ref;
38679         CHECK((*env)->GetArrayLength(env, val) == 32);
38680         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38681         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
38682 }
38683
38684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38685         LDKUnsignedChannelAnnouncement this_ptr_conv;
38686         this_ptr_conv.inner = untag_ptr(this_ptr);
38687         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38689         this_ptr_conv.is_owned = false;
38690         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
38691         return ret_conv;
38692 }
38693
38694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38695         LDKUnsignedChannelAnnouncement this_ptr_conv;
38696         this_ptr_conv.inner = untag_ptr(this_ptr);
38697         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38699         this_ptr_conv.is_owned = false;
38700         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
38701 }
38702
38703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38704         LDKUnsignedChannelAnnouncement this_ptr_conv;
38705         this_ptr_conv.inner = untag_ptr(this_ptr);
38706         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38708         this_ptr_conv.is_owned = false;
38709         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv);
38710         int64_t ret_ref = 0;
38711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38712         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38713         return ret_ref;
38714 }
38715
38716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38717         LDKUnsignedChannelAnnouncement this_ptr_conv;
38718         this_ptr_conv.inner = untag_ptr(this_ptr);
38719         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38721         this_ptr_conv.is_owned = false;
38722         LDKNodeId val_conv;
38723         val_conv.inner = untag_ptr(val);
38724         val_conv.is_owned = ptr_is_owned(val);
38725         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38726         val_conv = NodeId_clone(&val_conv);
38727         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_conv);
38728 }
38729
38730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38731         LDKUnsignedChannelAnnouncement this_ptr_conv;
38732         this_ptr_conv.inner = untag_ptr(this_ptr);
38733         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38735         this_ptr_conv.is_owned = false;
38736         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv);
38737         int64_t ret_ref = 0;
38738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38739         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38740         return ret_ref;
38741 }
38742
38743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38744         LDKUnsignedChannelAnnouncement this_ptr_conv;
38745         this_ptr_conv.inner = untag_ptr(this_ptr);
38746         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38748         this_ptr_conv.is_owned = false;
38749         LDKNodeId val_conv;
38750         val_conv.inner = untag_ptr(val);
38751         val_conv.is_owned = ptr_is_owned(val);
38752         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38753         val_conv = NodeId_clone(&val_conv);
38754         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_conv);
38755 }
38756
38757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
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         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv);
38764         int64_t ret_ref = 0;
38765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38766         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38767         return ret_ref;
38768 }
38769
38770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38771         LDKUnsignedChannelAnnouncement this_ptr_conv;
38772         this_ptr_conv.inner = untag_ptr(this_ptr);
38773         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38775         this_ptr_conv.is_owned = false;
38776         LDKNodeId val_conv;
38777         val_conv.inner = untag_ptr(val);
38778         val_conv.is_owned = ptr_is_owned(val);
38779         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38780         val_conv = NodeId_clone(&val_conv);
38781         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_conv);
38782 }
38783
38784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38785         LDKUnsignedChannelAnnouncement this_ptr_conv;
38786         this_ptr_conv.inner = untag_ptr(this_ptr);
38787         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38789         this_ptr_conv.is_owned = false;
38790         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv);
38791         int64_t ret_ref = 0;
38792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38793         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38794         return ret_ref;
38795 }
38796
38797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38798         LDKUnsignedChannelAnnouncement this_ptr_conv;
38799         this_ptr_conv.inner = untag_ptr(this_ptr);
38800         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38802         this_ptr_conv.is_owned = false;
38803         LDKNodeId val_conv;
38804         val_conv.inner = untag_ptr(val);
38805         val_conv.is_owned = ptr_is_owned(val);
38806         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38807         val_conv = NodeId_clone(&val_conv);
38808         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_conv);
38809 }
38810
38811 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
38812         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
38813         int64_t ret_ref = 0;
38814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38815         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38816         return ret_ref;
38817 }
38818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38819         LDKUnsignedChannelAnnouncement arg_conv;
38820         arg_conv.inner = untag_ptr(arg);
38821         arg_conv.is_owned = ptr_is_owned(arg);
38822         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38823         arg_conv.is_owned = false;
38824         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
38825         return ret_conv;
38826 }
38827
38828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38829         LDKUnsignedChannelAnnouncement orig_conv;
38830         orig_conv.inner = untag_ptr(orig);
38831         orig_conv.is_owned = ptr_is_owned(orig);
38832         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38833         orig_conv.is_owned = false;
38834         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
38835         int64_t ret_ref = 0;
38836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38837         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38838         return ret_ref;
38839 }
38840
38841 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38842         LDKUnsignedChannelAnnouncement a_conv;
38843         a_conv.inner = untag_ptr(a);
38844         a_conv.is_owned = ptr_is_owned(a);
38845         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38846         a_conv.is_owned = false;
38847         LDKUnsignedChannelAnnouncement b_conv;
38848         b_conv.inner = untag_ptr(b);
38849         b_conv.is_owned = ptr_is_owned(b);
38850         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38851         b_conv.is_owned = false;
38852         jboolean ret_conv = UnsignedChannelAnnouncement_eq(&a_conv, &b_conv);
38853         return ret_conv;
38854 }
38855
38856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38857         LDKChannelAnnouncement this_obj_conv;
38858         this_obj_conv.inner = untag_ptr(this_obj);
38859         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38861         ChannelAnnouncement_free(this_obj_conv);
38862 }
38863
38864 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38865         LDKChannelAnnouncement this_ptr_conv;
38866         this_ptr_conv.inner = untag_ptr(this_ptr);
38867         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38869         this_ptr_conv.is_owned = false;
38870         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38871         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
38872         return ret_arr;
38873 }
38874
38875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38876         LDKChannelAnnouncement this_ptr_conv;
38877         this_ptr_conv.inner = untag_ptr(this_ptr);
38878         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38880         this_ptr_conv.is_owned = false;
38881         LDKSignature val_ref;
38882         CHECK((*env)->GetArrayLength(env, val) == 64);
38883         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38884         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
38885 }
38886
38887 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38888         LDKChannelAnnouncement this_ptr_conv;
38889         this_ptr_conv.inner = untag_ptr(this_ptr);
38890         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38892         this_ptr_conv.is_owned = false;
38893         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38894         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
38895         return ret_arr;
38896 }
38897
38898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38899         LDKChannelAnnouncement this_ptr_conv;
38900         this_ptr_conv.inner = untag_ptr(this_ptr);
38901         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38903         this_ptr_conv.is_owned = false;
38904         LDKSignature val_ref;
38905         CHECK((*env)->GetArrayLength(env, val) == 64);
38906         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38907         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
38908 }
38909
38910 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38911         LDKChannelAnnouncement this_ptr_conv;
38912         this_ptr_conv.inner = untag_ptr(this_ptr);
38913         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38915         this_ptr_conv.is_owned = false;
38916         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38917         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
38918         return ret_arr;
38919 }
38920
38921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38922         LDKChannelAnnouncement this_ptr_conv;
38923         this_ptr_conv.inner = untag_ptr(this_ptr);
38924         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38926         this_ptr_conv.is_owned = false;
38927         LDKSignature val_ref;
38928         CHECK((*env)->GetArrayLength(env, val) == 64);
38929         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38930         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
38931 }
38932
38933 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38934         LDKChannelAnnouncement this_ptr_conv;
38935         this_ptr_conv.inner = untag_ptr(this_ptr);
38936         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38938         this_ptr_conv.is_owned = false;
38939         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38940         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
38941         return ret_arr;
38942 }
38943
38944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38945         LDKChannelAnnouncement this_ptr_conv;
38946         this_ptr_conv.inner = untag_ptr(this_ptr);
38947         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38949         this_ptr_conv.is_owned = false;
38950         LDKSignature val_ref;
38951         CHECK((*env)->GetArrayLength(env, val) == 64);
38952         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38953         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
38954 }
38955
38956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
38957         LDKChannelAnnouncement this_ptr_conv;
38958         this_ptr_conv.inner = untag_ptr(this_ptr);
38959         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38961         this_ptr_conv.is_owned = false;
38962         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
38963         int64_t ret_ref = 0;
38964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38965         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38966         return ret_ref;
38967 }
38968
38969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38970         LDKChannelAnnouncement this_ptr_conv;
38971         this_ptr_conv.inner = untag_ptr(this_ptr);
38972         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38974         this_ptr_conv.is_owned = false;
38975         LDKUnsignedChannelAnnouncement val_conv;
38976         val_conv.inner = untag_ptr(val);
38977         val_conv.is_owned = ptr_is_owned(val);
38978         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38979         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
38980         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
38981 }
38982
38983 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) {
38984         LDKSignature node_signature_1_arg_ref;
38985         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
38986         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
38987         LDKSignature node_signature_2_arg_ref;
38988         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
38989         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
38990         LDKSignature bitcoin_signature_1_arg_ref;
38991         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
38992         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
38993         LDKSignature bitcoin_signature_2_arg_ref;
38994         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
38995         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
38996         LDKUnsignedChannelAnnouncement contents_arg_conv;
38997         contents_arg_conv.inner = untag_ptr(contents_arg);
38998         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
38999         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
39000         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
39001         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);
39002         int64_t ret_ref = 0;
39003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39004         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39005         return ret_ref;
39006 }
39007
39008 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
39009         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
39010         int64_t ret_ref = 0;
39011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39012         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39013         return ret_ref;
39014 }
39015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39016         LDKChannelAnnouncement arg_conv;
39017         arg_conv.inner = untag_ptr(arg);
39018         arg_conv.is_owned = ptr_is_owned(arg);
39019         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39020         arg_conv.is_owned = false;
39021         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
39022         return ret_conv;
39023 }
39024
39025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39026         LDKChannelAnnouncement orig_conv;
39027         orig_conv.inner = untag_ptr(orig);
39028         orig_conv.is_owned = ptr_is_owned(orig);
39029         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39030         orig_conv.is_owned = false;
39031         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
39032         int64_t ret_ref = 0;
39033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39034         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39035         return ret_ref;
39036 }
39037
39038 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39039         LDKChannelAnnouncement a_conv;
39040         a_conv.inner = untag_ptr(a);
39041         a_conv.is_owned = ptr_is_owned(a);
39042         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39043         a_conv.is_owned = false;
39044         LDKChannelAnnouncement b_conv;
39045         b_conv.inner = untag_ptr(b);
39046         b_conv.is_owned = ptr_is_owned(b);
39047         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39048         b_conv.is_owned = false;
39049         jboolean ret_conv = ChannelAnnouncement_eq(&a_conv, &b_conv);
39050         return ret_conv;
39051 }
39052
39053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39054         LDKUnsignedChannelUpdate this_obj_conv;
39055         this_obj_conv.inner = untag_ptr(this_obj);
39056         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39058         UnsignedChannelUpdate_free(this_obj_conv);
39059 }
39060
39061 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39062         LDKUnsignedChannelUpdate this_ptr_conv;
39063         this_ptr_conv.inner = untag_ptr(this_ptr);
39064         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39066         this_ptr_conv.is_owned = false;
39067         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39068         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
39069         return ret_arr;
39070 }
39071
39072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39073         LDKUnsignedChannelUpdate this_ptr_conv;
39074         this_ptr_conv.inner = untag_ptr(this_ptr);
39075         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39077         this_ptr_conv.is_owned = false;
39078         LDKThirtyTwoBytes val_ref;
39079         CHECK((*env)->GetArrayLength(env, val) == 32);
39080         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39081         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
39082 }
39083
39084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
39085         LDKUnsignedChannelUpdate this_ptr_conv;
39086         this_ptr_conv.inner = untag_ptr(this_ptr);
39087         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39089         this_ptr_conv.is_owned = false;
39090         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
39091         return ret_conv;
39092 }
39093
39094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39095         LDKUnsignedChannelUpdate this_ptr_conv;
39096         this_ptr_conv.inner = untag_ptr(this_ptr);
39097         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39099         this_ptr_conv.is_owned = false;
39100         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
39101 }
39102
39103 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
39104         LDKUnsignedChannelUpdate this_ptr_conv;
39105         this_ptr_conv.inner = untag_ptr(this_ptr);
39106         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39108         this_ptr_conv.is_owned = false;
39109         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
39110         return ret_conv;
39111 }
39112
39113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39114         LDKUnsignedChannelUpdate this_ptr_conv;
39115         this_ptr_conv.inner = untag_ptr(this_ptr);
39116         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39118         this_ptr_conv.is_owned = false;
39119         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
39120 }
39121
39122 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
39123         LDKUnsignedChannelUpdate this_ptr_conv;
39124         this_ptr_conv.inner = untag_ptr(this_ptr);
39125         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39127         this_ptr_conv.is_owned = false;
39128         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
39129         return ret_conv;
39130 }
39131
39132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
39133         LDKUnsignedChannelUpdate this_ptr_conv;
39134         this_ptr_conv.inner = untag_ptr(this_ptr);
39135         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39137         this_ptr_conv.is_owned = false;
39138         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
39139 }
39140
39141 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
39142         LDKUnsignedChannelUpdate this_ptr_conv;
39143         this_ptr_conv.inner = untag_ptr(this_ptr);
39144         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39146         this_ptr_conv.is_owned = false;
39147         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
39148         return ret_conv;
39149 }
39150
39151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
39152         LDKUnsignedChannelUpdate this_ptr_conv;
39153         this_ptr_conv.inner = untag_ptr(this_ptr);
39154         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39156         this_ptr_conv.is_owned = false;
39157         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
39158 }
39159
39160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39161         LDKUnsignedChannelUpdate this_ptr_conv;
39162         this_ptr_conv.inner = untag_ptr(this_ptr);
39163         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39165         this_ptr_conv.is_owned = false;
39166         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
39167         return ret_conv;
39168 }
39169
39170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39171         LDKUnsignedChannelUpdate this_ptr_conv;
39172         this_ptr_conv.inner = untag_ptr(this_ptr);
39173         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39175         this_ptr_conv.is_owned = false;
39176         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
39177 }
39178
39179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39180         LDKUnsignedChannelUpdate this_ptr_conv;
39181         this_ptr_conv.inner = untag_ptr(this_ptr);
39182         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39184         this_ptr_conv.is_owned = false;
39185         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
39186         return ret_conv;
39187 }
39188
39189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39190         LDKUnsignedChannelUpdate this_ptr_conv;
39191         this_ptr_conv.inner = untag_ptr(this_ptr);
39192         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39194         this_ptr_conv.is_owned = false;
39195         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
39196 }
39197
39198 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39199         LDKUnsignedChannelUpdate this_ptr_conv;
39200         this_ptr_conv.inner = untag_ptr(this_ptr);
39201         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39203         this_ptr_conv.is_owned = false;
39204         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
39205         return ret_conv;
39206 }
39207
39208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39209         LDKUnsignedChannelUpdate this_ptr_conv;
39210         this_ptr_conv.inner = untag_ptr(this_ptr);
39211         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39213         this_ptr_conv.is_owned = false;
39214         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
39215 }
39216
39217 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
39218         LDKUnsignedChannelUpdate this_ptr_conv;
39219         this_ptr_conv.inner = untag_ptr(this_ptr);
39220         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39222         this_ptr_conv.is_owned = false;
39223         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
39224         return ret_conv;
39225 }
39226
39227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39228         LDKUnsignedChannelUpdate this_ptr_conv;
39229         this_ptr_conv.inner = untag_ptr(this_ptr);
39230         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39232         this_ptr_conv.is_owned = false;
39233         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
39234 }
39235
39236 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
39237         LDKUnsignedChannelUpdate this_ptr_conv;
39238         this_ptr_conv.inner = untag_ptr(this_ptr);
39239         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39241         this_ptr_conv.is_owned = false;
39242         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
39243         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39244         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39245         CVec_u8Z_free(ret_var);
39246         return ret_arr;
39247 }
39248
39249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39250         LDKUnsignedChannelUpdate this_ptr_conv;
39251         this_ptr_conv.inner = untag_ptr(this_ptr);
39252         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39254         this_ptr_conv.is_owned = false;
39255         LDKCVec_u8Z val_ref;
39256         val_ref.datalen = (*env)->GetArrayLength(env, val);
39257         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
39258         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
39259         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
39260 }
39261
39262 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) {
39263         LDKThirtyTwoBytes chain_hash_arg_ref;
39264         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39265         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39266         LDKCVec_u8Z excess_data_arg_ref;
39267         excess_data_arg_ref.datalen = (*env)->GetArrayLength(env, excess_data_arg);
39268         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
39269         (*env)->GetByteArrayRegion(env, excess_data_arg, 0, excess_data_arg_ref.datalen, excess_data_arg_ref.data);
39270         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);
39271         int64_t ret_ref = 0;
39272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39273         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39274         return ret_ref;
39275 }
39276
39277 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
39278         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
39279         int64_t ret_ref = 0;
39280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39281         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39282         return ret_ref;
39283 }
39284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39285         LDKUnsignedChannelUpdate arg_conv;
39286         arg_conv.inner = untag_ptr(arg);
39287         arg_conv.is_owned = ptr_is_owned(arg);
39288         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39289         arg_conv.is_owned = false;
39290         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
39291         return ret_conv;
39292 }
39293
39294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39295         LDKUnsignedChannelUpdate orig_conv;
39296         orig_conv.inner = untag_ptr(orig);
39297         orig_conv.is_owned = ptr_is_owned(orig);
39298         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39299         orig_conv.is_owned = false;
39300         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
39301         int64_t ret_ref = 0;
39302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39303         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39304         return ret_ref;
39305 }
39306
39307 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39308         LDKUnsignedChannelUpdate a_conv;
39309         a_conv.inner = untag_ptr(a);
39310         a_conv.is_owned = ptr_is_owned(a);
39311         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39312         a_conv.is_owned = false;
39313         LDKUnsignedChannelUpdate b_conv;
39314         b_conv.inner = untag_ptr(b);
39315         b_conv.is_owned = ptr_is_owned(b);
39316         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39317         b_conv.is_owned = false;
39318         jboolean ret_conv = UnsignedChannelUpdate_eq(&a_conv, &b_conv);
39319         return ret_conv;
39320 }
39321
39322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39323         LDKChannelUpdate this_obj_conv;
39324         this_obj_conv.inner = untag_ptr(this_obj);
39325         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39327         ChannelUpdate_free(this_obj_conv);
39328 }
39329
39330 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
39331         LDKChannelUpdate this_ptr_conv;
39332         this_ptr_conv.inner = untag_ptr(this_ptr);
39333         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39335         this_ptr_conv.is_owned = false;
39336         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39337         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
39338         return ret_arr;
39339 }
39340
39341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39342         LDKChannelUpdate this_ptr_conv;
39343         this_ptr_conv.inner = untag_ptr(this_ptr);
39344         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39346         this_ptr_conv.is_owned = false;
39347         LDKSignature val_ref;
39348         CHECK((*env)->GetArrayLength(env, val) == 64);
39349         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
39350         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
39351 }
39352
39353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
39354         LDKChannelUpdate this_ptr_conv;
39355         this_ptr_conv.inner = untag_ptr(this_ptr);
39356         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39358         this_ptr_conv.is_owned = false;
39359         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
39360         int64_t ret_ref = 0;
39361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39362         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39363         return ret_ref;
39364 }
39365
39366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39367         LDKChannelUpdate this_ptr_conv;
39368         this_ptr_conv.inner = untag_ptr(this_ptr);
39369         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39371         this_ptr_conv.is_owned = false;
39372         LDKUnsignedChannelUpdate val_conv;
39373         val_conv.inner = untag_ptr(val);
39374         val_conv.is_owned = ptr_is_owned(val);
39375         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39376         val_conv = UnsignedChannelUpdate_clone(&val_conv);
39377         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
39378 }
39379
39380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
39381         LDKSignature signature_arg_ref;
39382         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
39383         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
39384         LDKUnsignedChannelUpdate contents_arg_conv;
39385         contents_arg_conv.inner = untag_ptr(contents_arg);
39386         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
39387         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
39388         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
39389         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
39390         int64_t ret_ref = 0;
39391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39392         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39393         return ret_ref;
39394 }
39395
39396 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
39397         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
39398         int64_t ret_ref = 0;
39399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39400         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39401         return ret_ref;
39402 }
39403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39404         LDKChannelUpdate arg_conv;
39405         arg_conv.inner = untag_ptr(arg);
39406         arg_conv.is_owned = ptr_is_owned(arg);
39407         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39408         arg_conv.is_owned = false;
39409         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
39410         return ret_conv;
39411 }
39412
39413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39414         LDKChannelUpdate orig_conv;
39415         orig_conv.inner = untag_ptr(orig);
39416         orig_conv.is_owned = ptr_is_owned(orig);
39417         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39418         orig_conv.is_owned = false;
39419         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
39420         int64_t ret_ref = 0;
39421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39422         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39423         return ret_ref;
39424 }
39425
39426 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39427         LDKChannelUpdate a_conv;
39428         a_conv.inner = untag_ptr(a);
39429         a_conv.is_owned = ptr_is_owned(a);
39430         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39431         a_conv.is_owned = false;
39432         LDKChannelUpdate b_conv;
39433         b_conv.inner = untag_ptr(b);
39434         b_conv.is_owned = ptr_is_owned(b);
39435         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39436         b_conv.is_owned = false;
39437         jboolean ret_conv = ChannelUpdate_eq(&a_conv, &b_conv);
39438         return ret_conv;
39439 }
39440
39441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39442         LDKQueryChannelRange this_obj_conv;
39443         this_obj_conv.inner = untag_ptr(this_obj);
39444         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39446         QueryChannelRange_free(this_obj_conv);
39447 }
39448
39449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39450         LDKQueryChannelRange this_ptr_conv;
39451         this_ptr_conv.inner = untag_ptr(this_ptr);
39452         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39454         this_ptr_conv.is_owned = false;
39455         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39456         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
39457         return ret_arr;
39458 }
39459
39460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39461         LDKQueryChannelRange this_ptr_conv;
39462         this_ptr_conv.inner = untag_ptr(this_ptr);
39463         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39465         this_ptr_conv.is_owned = false;
39466         LDKThirtyTwoBytes val_ref;
39467         CHECK((*env)->GetArrayLength(env, val) == 32);
39468         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39469         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
39470 }
39471
39472 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
39473         LDKQueryChannelRange this_ptr_conv;
39474         this_ptr_conv.inner = untag_ptr(this_ptr);
39475         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39477         this_ptr_conv.is_owned = false;
39478         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
39479         return ret_conv;
39480 }
39481
39482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39483         LDKQueryChannelRange this_ptr_conv;
39484         this_ptr_conv.inner = untag_ptr(this_ptr);
39485         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39487         this_ptr_conv.is_owned = false;
39488         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
39489 }
39490
39491 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
39492         LDKQueryChannelRange this_ptr_conv;
39493         this_ptr_conv.inner = untag_ptr(this_ptr);
39494         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39496         this_ptr_conv.is_owned = false;
39497         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
39498         return ret_conv;
39499 }
39500
39501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39502         LDKQueryChannelRange this_ptr_conv;
39503         this_ptr_conv.inner = untag_ptr(this_ptr);
39504         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39506         this_ptr_conv.is_owned = false;
39507         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
39508 }
39509
39510 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) {
39511         LDKThirtyTwoBytes chain_hash_arg_ref;
39512         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39513         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39514         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
39515         int64_t ret_ref = 0;
39516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39517         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39518         return ret_ref;
39519 }
39520
39521 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
39522         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
39523         int64_t ret_ref = 0;
39524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39525         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39526         return ret_ref;
39527 }
39528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39529         LDKQueryChannelRange arg_conv;
39530         arg_conv.inner = untag_ptr(arg);
39531         arg_conv.is_owned = ptr_is_owned(arg);
39532         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39533         arg_conv.is_owned = false;
39534         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
39535         return ret_conv;
39536 }
39537
39538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39539         LDKQueryChannelRange orig_conv;
39540         orig_conv.inner = untag_ptr(orig);
39541         orig_conv.is_owned = ptr_is_owned(orig);
39542         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39543         orig_conv.is_owned = false;
39544         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
39545         int64_t ret_ref = 0;
39546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39547         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39548         return ret_ref;
39549 }
39550
39551 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39552         LDKQueryChannelRange a_conv;
39553         a_conv.inner = untag_ptr(a);
39554         a_conv.is_owned = ptr_is_owned(a);
39555         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39556         a_conv.is_owned = false;
39557         LDKQueryChannelRange b_conv;
39558         b_conv.inner = untag_ptr(b);
39559         b_conv.is_owned = ptr_is_owned(b);
39560         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39561         b_conv.is_owned = false;
39562         jboolean ret_conv = QueryChannelRange_eq(&a_conv, &b_conv);
39563         return ret_conv;
39564 }
39565
39566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39567         LDKReplyChannelRange this_obj_conv;
39568         this_obj_conv.inner = untag_ptr(this_obj);
39569         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39571         ReplyChannelRange_free(this_obj_conv);
39572 }
39573
39574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39575         LDKReplyChannelRange this_ptr_conv;
39576         this_ptr_conv.inner = untag_ptr(this_ptr);
39577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39579         this_ptr_conv.is_owned = false;
39580         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39581         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
39582         return ret_arr;
39583 }
39584
39585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39586         LDKReplyChannelRange this_ptr_conv;
39587         this_ptr_conv.inner = untag_ptr(this_ptr);
39588         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39590         this_ptr_conv.is_owned = false;
39591         LDKThirtyTwoBytes val_ref;
39592         CHECK((*env)->GetArrayLength(env, val) == 32);
39593         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39594         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
39595 }
39596
39597 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
39598         LDKReplyChannelRange this_ptr_conv;
39599         this_ptr_conv.inner = untag_ptr(this_ptr);
39600         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39602         this_ptr_conv.is_owned = false;
39603         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
39604         return ret_conv;
39605 }
39606
39607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39608         LDKReplyChannelRange this_ptr_conv;
39609         this_ptr_conv.inner = untag_ptr(this_ptr);
39610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39612         this_ptr_conv.is_owned = false;
39613         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
39614 }
39615
39616 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
39617         LDKReplyChannelRange this_ptr_conv;
39618         this_ptr_conv.inner = untag_ptr(this_ptr);
39619         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39621         this_ptr_conv.is_owned = false;
39622         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
39623         return ret_conv;
39624 }
39625
39626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39627         LDKReplyChannelRange this_ptr_conv;
39628         this_ptr_conv.inner = untag_ptr(this_ptr);
39629         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39631         this_ptr_conv.is_owned = false;
39632         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
39633 }
39634
39635 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
39636         LDKReplyChannelRange this_ptr_conv;
39637         this_ptr_conv.inner = untag_ptr(this_ptr);
39638         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39640         this_ptr_conv.is_owned = false;
39641         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
39642         return ret_conv;
39643 }
39644
39645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39646         LDKReplyChannelRange this_ptr_conv;
39647         this_ptr_conv.inner = untag_ptr(this_ptr);
39648         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39650         this_ptr_conv.is_owned = false;
39651         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
39652 }
39653
39654 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
39655         LDKReplyChannelRange this_ptr_conv;
39656         this_ptr_conv.inner = untag_ptr(this_ptr);
39657         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39659         this_ptr_conv.is_owned = false;
39660         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
39661         int64_tArray ret_arr = NULL;
39662         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39663         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39664         for (size_t g = 0; g < ret_var.datalen; g++) {
39665                 int64_t ret_conv_6_conv = ret_var.data[g];
39666                 ret_arr_ptr[g] = ret_conv_6_conv;
39667         }
39668         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39669         FREE(ret_var.data);
39670         return ret_arr;
39671 }
39672
39673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39674         LDKReplyChannelRange this_ptr_conv;
39675         this_ptr_conv.inner = untag_ptr(this_ptr);
39676         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39678         this_ptr_conv.is_owned = false;
39679         LDKCVec_u64Z val_constr;
39680         val_constr.datalen = (*env)->GetArrayLength(env, val);
39681         if (val_constr.datalen > 0)
39682                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39683         else
39684                 val_constr.data = NULL;
39685         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39686         for (size_t g = 0; g < val_constr.datalen; g++) {
39687                 int64_t val_conv_6 = val_vals[g];
39688                 val_constr.data[g] = val_conv_6;
39689         }
39690         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39691         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
39692 }
39693
39694 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) {
39695         LDKThirtyTwoBytes chain_hash_arg_ref;
39696         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39697         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39698         LDKCVec_u64Z short_channel_ids_arg_constr;
39699         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
39700         if (short_channel_ids_arg_constr.datalen > 0)
39701                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39702         else
39703                 short_channel_ids_arg_constr.data = NULL;
39704         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
39705         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
39706                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
39707                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
39708         }
39709         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
39710         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
39711         int64_t ret_ref = 0;
39712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39713         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39714         return ret_ref;
39715 }
39716
39717 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
39718         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
39719         int64_t ret_ref = 0;
39720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39721         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39722         return ret_ref;
39723 }
39724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39725         LDKReplyChannelRange arg_conv;
39726         arg_conv.inner = untag_ptr(arg);
39727         arg_conv.is_owned = ptr_is_owned(arg);
39728         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39729         arg_conv.is_owned = false;
39730         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
39731         return ret_conv;
39732 }
39733
39734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39735         LDKReplyChannelRange orig_conv;
39736         orig_conv.inner = untag_ptr(orig);
39737         orig_conv.is_owned = ptr_is_owned(orig);
39738         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39739         orig_conv.is_owned = false;
39740         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
39741         int64_t ret_ref = 0;
39742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39743         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39744         return ret_ref;
39745 }
39746
39747 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39748         LDKReplyChannelRange a_conv;
39749         a_conv.inner = untag_ptr(a);
39750         a_conv.is_owned = ptr_is_owned(a);
39751         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39752         a_conv.is_owned = false;
39753         LDKReplyChannelRange b_conv;
39754         b_conv.inner = untag_ptr(b);
39755         b_conv.is_owned = ptr_is_owned(b);
39756         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39757         b_conv.is_owned = false;
39758         jboolean ret_conv = ReplyChannelRange_eq(&a_conv, &b_conv);
39759         return ret_conv;
39760 }
39761
39762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39763         LDKQueryShortChannelIds this_obj_conv;
39764         this_obj_conv.inner = untag_ptr(this_obj);
39765         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39767         QueryShortChannelIds_free(this_obj_conv);
39768 }
39769
39770 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39771         LDKQueryShortChannelIds this_ptr_conv;
39772         this_ptr_conv.inner = untag_ptr(this_ptr);
39773         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39775         this_ptr_conv.is_owned = false;
39776         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39777         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
39778         return ret_arr;
39779 }
39780
39781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39782         LDKQueryShortChannelIds this_ptr_conv;
39783         this_ptr_conv.inner = untag_ptr(this_ptr);
39784         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39786         this_ptr_conv.is_owned = false;
39787         LDKThirtyTwoBytes val_ref;
39788         CHECK((*env)->GetArrayLength(env, val) == 32);
39789         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39790         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
39791 }
39792
39793 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
39794         LDKQueryShortChannelIds this_ptr_conv;
39795         this_ptr_conv.inner = untag_ptr(this_ptr);
39796         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39798         this_ptr_conv.is_owned = false;
39799         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
39800         int64_tArray ret_arr = NULL;
39801         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39802         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39803         for (size_t g = 0; g < ret_var.datalen; g++) {
39804                 int64_t ret_conv_6_conv = ret_var.data[g];
39805                 ret_arr_ptr[g] = ret_conv_6_conv;
39806         }
39807         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39808         FREE(ret_var.data);
39809         return ret_arr;
39810 }
39811
39812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39813         LDKQueryShortChannelIds this_ptr_conv;
39814         this_ptr_conv.inner = untag_ptr(this_ptr);
39815         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39817         this_ptr_conv.is_owned = false;
39818         LDKCVec_u64Z val_constr;
39819         val_constr.datalen = (*env)->GetArrayLength(env, val);
39820         if (val_constr.datalen > 0)
39821                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39822         else
39823                 val_constr.data = NULL;
39824         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39825         for (size_t g = 0; g < val_constr.datalen; g++) {
39826                 int64_t val_conv_6 = val_vals[g];
39827                 val_constr.data[g] = val_conv_6;
39828         }
39829         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39830         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
39831 }
39832
39833 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) {
39834         LDKThirtyTwoBytes chain_hash_arg_ref;
39835         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39836         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39837         LDKCVec_u64Z short_channel_ids_arg_constr;
39838         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
39839         if (short_channel_ids_arg_constr.datalen > 0)
39840                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39841         else
39842                 short_channel_ids_arg_constr.data = NULL;
39843         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
39844         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
39845                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
39846                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
39847         }
39848         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
39849         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
39850         int64_t ret_ref = 0;
39851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39852         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39853         return ret_ref;
39854 }
39855
39856 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
39857         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
39858         int64_t ret_ref = 0;
39859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39860         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39861         return ret_ref;
39862 }
39863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39864         LDKQueryShortChannelIds arg_conv;
39865         arg_conv.inner = untag_ptr(arg);
39866         arg_conv.is_owned = ptr_is_owned(arg);
39867         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39868         arg_conv.is_owned = false;
39869         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
39870         return ret_conv;
39871 }
39872
39873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39874         LDKQueryShortChannelIds orig_conv;
39875         orig_conv.inner = untag_ptr(orig);
39876         orig_conv.is_owned = ptr_is_owned(orig);
39877         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39878         orig_conv.is_owned = false;
39879         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
39880         int64_t ret_ref = 0;
39881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39882         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39883         return ret_ref;
39884 }
39885
39886 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39887         LDKQueryShortChannelIds a_conv;
39888         a_conv.inner = untag_ptr(a);
39889         a_conv.is_owned = ptr_is_owned(a);
39890         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39891         a_conv.is_owned = false;
39892         LDKQueryShortChannelIds b_conv;
39893         b_conv.inner = untag_ptr(b);
39894         b_conv.is_owned = ptr_is_owned(b);
39895         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39896         b_conv.is_owned = false;
39897         jboolean ret_conv = QueryShortChannelIds_eq(&a_conv, &b_conv);
39898         return ret_conv;
39899 }
39900
39901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39902         LDKReplyShortChannelIdsEnd this_obj_conv;
39903         this_obj_conv.inner = untag_ptr(this_obj);
39904         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39906         ReplyShortChannelIdsEnd_free(this_obj_conv);
39907 }
39908
39909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39910         LDKReplyShortChannelIdsEnd this_ptr_conv;
39911         this_ptr_conv.inner = untag_ptr(this_ptr);
39912         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39914         this_ptr_conv.is_owned = false;
39915         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39916         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
39917         return ret_arr;
39918 }
39919
39920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39921         LDKReplyShortChannelIdsEnd this_ptr_conv;
39922         this_ptr_conv.inner = untag_ptr(this_ptr);
39923         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39925         this_ptr_conv.is_owned = false;
39926         LDKThirtyTwoBytes val_ref;
39927         CHECK((*env)->GetArrayLength(env, val) == 32);
39928         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39929         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
39930 }
39931
39932 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
39933         LDKReplyShortChannelIdsEnd this_ptr_conv;
39934         this_ptr_conv.inner = untag_ptr(this_ptr);
39935         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39937         this_ptr_conv.is_owned = false;
39938         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
39939         return ret_conv;
39940 }
39941
39942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39943         LDKReplyShortChannelIdsEnd this_ptr_conv;
39944         this_ptr_conv.inner = untag_ptr(this_ptr);
39945         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39947         this_ptr_conv.is_owned = false;
39948         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
39949 }
39950
39951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
39952         LDKThirtyTwoBytes chain_hash_arg_ref;
39953         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39954         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39955         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
39956         int64_t ret_ref = 0;
39957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39958         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39959         return ret_ref;
39960 }
39961
39962 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
39963         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
39964         int64_t ret_ref = 0;
39965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39966         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39967         return ret_ref;
39968 }
39969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39970         LDKReplyShortChannelIdsEnd arg_conv;
39971         arg_conv.inner = untag_ptr(arg);
39972         arg_conv.is_owned = ptr_is_owned(arg);
39973         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39974         arg_conv.is_owned = false;
39975         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
39976         return ret_conv;
39977 }
39978
39979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39980         LDKReplyShortChannelIdsEnd orig_conv;
39981         orig_conv.inner = untag_ptr(orig);
39982         orig_conv.is_owned = ptr_is_owned(orig);
39983         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39984         orig_conv.is_owned = false;
39985         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
39986         int64_t ret_ref = 0;
39987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39989         return ret_ref;
39990 }
39991
39992 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39993         LDKReplyShortChannelIdsEnd a_conv;
39994         a_conv.inner = untag_ptr(a);
39995         a_conv.is_owned = ptr_is_owned(a);
39996         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39997         a_conv.is_owned = false;
39998         LDKReplyShortChannelIdsEnd b_conv;
39999         b_conv.inner = untag_ptr(b);
40000         b_conv.is_owned = ptr_is_owned(b);
40001         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40002         b_conv.is_owned = false;
40003         jboolean ret_conv = ReplyShortChannelIdsEnd_eq(&a_conv, &b_conv);
40004         return ret_conv;
40005 }
40006
40007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40008         LDKGossipTimestampFilter this_obj_conv;
40009         this_obj_conv.inner = untag_ptr(this_obj);
40010         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40012         GossipTimestampFilter_free(this_obj_conv);
40013 }
40014
40015 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
40016         LDKGossipTimestampFilter this_ptr_conv;
40017         this_ptr_conv.inner = untag_ptr(this_ptr);
40018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40020         this_ptr_conv.is_owned = false;
40021         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40022         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
40023         return ret_arr;
40024 }
40025
40026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40027         LDKGossipTimestampFilter this_ptr_conv;
40028         this_ptr_conv.inner = untag_ptr(this_ptr);
40029         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40031         this_ptr_conv.is_owned = false;
40032         LDKThirtyTwoBytes val_ref;
40033         CHECK((*env)->GetArrayLength(env, val) == 32);
40034         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40035         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
40036 }
40037
40038 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
40039         LDKGossipTimestampFilter this_ptr_conv;
40040         this_ptr_conv.inner = untag_ptr(this_ptr);
40041         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40043         this_ptr_conv.is_owned = false;
40044         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
40045         return ret_conv;
40046 }
40047
40048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40049         LDKGossipTimestampFilter this_ptr_conv;
40050         this_ptr_conv.inner = untag_ptr(this_ptr);
40051         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40053         this_ptr_conv.is_owned = false;
40054         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
40055 }
40056
40057 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
40058         LDKGossipTimestampFilter this_ptr_conv;
40059         this_ptr_conv.inner = untag_ptr(this_ptr);
40060         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40062         this_ptr_conv.is_owned = false;
40063         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
40064         return ret_conv;
40065 }
40066
40067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40068         LDKGossipTimestampFilter this_ptr_conv;
40069         this_ptr_conv.inner = untag_ptr(this_ptr);
40070         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40072         this_ptr_conv.is_owned = false;
40073         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
40074 }
40075
40076 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) {
40077         LDKThirtyTwoBytes chain_hash_arg_ref;
40078         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
40079         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
40080         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
40081         int64_t ret_ref = 0;
40082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40083         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40084         return ret_ref;
40085 }
40086
40087 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
40088         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
40089         int64_t ret_ref = 0;
40090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40091         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40092         return ret_ref;
40093 }
40094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40095         LDKGossipTimestampFilter arg_conv;
40096         arg_conv.inner = untag_ptr(arg);
40097         arg_conv.is_owned = ptr_is_owned(arg);
40098         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40099         arg_conv.is_owned = false;
40100         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
40101         return ret_conv;
40102 }
40103
40104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40105         LDKGossipTimestampFilter orig_conv;
40106         orig_conv.inner = untag_ptr(orig);
40107         orig_conv.is_owned = ptr_is_owned(orig);
40108         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40109         orig_conv.is_owned = false;
40110         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
40111         int64_t ret_ref = 0;
40112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40113         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40114         return ret_ref;
40115 }
40116
40117 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40118         LDKGossipTimestampFilter a_conv;
40119         a_conv.inner = untag_ptr(a);
40120         a_conv.is_owned = ptr_is_owned(a);
40121         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40122         a_conv.is_owned = false;
40123         LDKGossipTimestampFilter b_conv;
40124         b_conv.inner = untag_ptr(b);
40125         b_conv.is_owned = ptr_is_owned(b);
40126         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40127         b_conv.is_owned = false;
40128         jboolean ret_conv = GossipTimestampFilter_eq(&a_conv, &b_conv);
40129         return ret_conv;
40130 }
40131
40132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40133         if (!ptr_is_owned(this_ptr)) return;
40134         void* this_ptr_ptr = untag_ptr(this_ptr);
40135         CHECK_ACCESS(this_ptr_ptr);
40136         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
40137         FREE(untag_ptr(this_ptr));
40138         ErrorAction_free(this_ptr_conv);
40139 }
40140
40141 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
40142         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40143         *ret_copy = ErrorAction_clone(arg);
40144         int64_t ret_ref = tag_ptr(ret_copy, true);
40145         return ret_ref;
40146 }
40147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40148         LDKErrorAction* arg_conv = (LDKErrorAction*)untag_ptr(arg);
40149         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
40150         return ret_conv;
40151 }
40152
40153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40154         LDKErrorAction* orig_conv = (LDKErrorAction*)untag_ptr(orig);
40155         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40156         *ret_copy = ErrorAction_clone(orig_conv);
40157         int64_t ret_ref = tag_ptr(ret_copy, true);
40158         return ret_ref;
40159 }
40160
40161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
40162         LDKErrorMessage msg_conv;
40163         msg_conv.inner = untag_ptr(msg);
40164         msg_conv.is_owned = ptr_is_owned(msg);
40165         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40166         msg_conv = ErrorMessage_clone(&msg_conv);
40167         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40168         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
40169         int64_t ret_ref = tag_ptr(ret_copy, true);
40170         return ret_ref;
40171 }
40172
40173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
40174         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40175         *ret_copy = ErrorAction_ignore_error();
40176         int64_t ret_ref = tag_ptr(ret_copy, true);
40177         return ret_ref;
40178 }
40179
40180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
40181         LDKLevel a_conv = LDKLevel_from_java(env, a);
40182         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40183         *ret_copy = ErrorAction_ignore_and_log(a_conv);
40184         int64_t ret_ref = tag_ptr(ret_copy, true);
40185         return ret_ref;
40186 }
40187
40188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
40189         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40190         *ret_copy = ErrorAction_ignore_duplicate_gossip();
40191         int64_t ret_ref = tag_ptr(ret_copy, true);
40192         return ret_ref;
40193 }
40194
40195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
40196         LDKErrorMessage msg_conv;
40197         msg_conv.inner = untag_ptr(msg);
40198         msg_conv.is_owned = ptr_is_owned(msg);
40199         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40200         msg_conv = ErrorMessage_clone(&msg_conv);
40201         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40202         *ret_copy = ErrorAction_send_error_message(msg_conv);
40203         int64_t ret_ref = tag_ptr(ret_copy, true);
40204         return ret_ref;
40205 }
40206
40207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
40208         LDKWarningMessage msg_conv;
40209         msg_conv.inner = untag_ptr(msg);
40210         msg_conv.is_owned = ptr_is_owned(msg);
40211         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40212         msg_conv = WarningMessage_clone(&msg_conv);
40213         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
40214         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40215         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
40216         int64_t ret_ref = tag_ptr(ret_copy, true);
40217         return ret_ref;
40218 }
40219
40220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40221         LDKLightningError this_obj_conv;
40222         this_obj_conv.inner = untag_ptr(this_obj);
40223         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40225         LightningError_free(this_obj_conv);
40226 }
40227
40228 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
40229         LDKLightningError this_ptr_conv;
40230         this_ptr_conv.inner = untag_ptr(this_ptr);
40231         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40233         this_ptr_conv.is_owned = false;
40234         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
40235         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40236         Str_free(ret_str);
40237         return ret_conv;
40238 }
40239
40240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
40241         LDKLightningError this_ptr_conv;
40242         this_ptr_conv.inner = untag_ptr(this_ptr);
40243         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40245         this_ptr_conv.is_owned = false;
40246         LDKStr val_conv = java_to_owned_str(env, val);
40247         LightningError_set_err(&this_ptr_conv, val_conv);
40248 }
40249
40250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
40251         LDKLightningError this_ptr_conv;
40252         this_ptr_conv.inner = untag_ptr(this_ptr);
40253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40255         this_ptr_conv.is_owned = false;
40256         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40257         *ret_copy = LightningError_get_action(&this_ptr_conv);
40258         int64_t ret_ref = tag_ptr(ret_copy, true);
40259         return ret_ref;
40260 }
40261
40262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40263         LDKLightningError this_ptr_conv;
40264         this_ptr_conv.inner = untag_ptr(this_ptr);
40265         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40267         this_ptr_conv.is_owned = false;
40268         void* val_ptr = untag_ptr(val);
40269         CHECK_ACCESS(val_ptr);
40270         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
40271         val_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(val));
40272         LightningError_set_action(&this_ptr_conv, val_conv);
40273 }
40274
40275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
40276         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
40277         void* action_arg_ptr = untag_ptr(action_arg);
40278         CHECK_ACCESS(action_arg_ptr);
40279         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
40280         action_arg_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action_arg));
40281         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
40282         int64_t ret_ref = 0;
40283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40284         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40285         return ret_ref;
40286 }
40287
40288 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
40289         LDKLightningError ret_var = LightningError_clone(arg);
40290         int64_t ret_ref = 0;
40291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40292         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40293         return ret_ref;
40294 }
40295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40296         LDKLightningError arg_conv;
40297         arg_conv.inner = untag_ptr(arg);
40298         arg_conv.is_owned = ptr_is_owned(arg);
40299         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40300         arg_conv.is_owned = false;
40301         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
40302         return ret_conv;
40303 }
40304
40305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40306         LDKLightningError orig_conv;
40307         orig_conv.inner = untag_ptr(orig);
40308         orig_conv.is_owned = ptr_is_owned(orig);
40309         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40310         orig_conv.is_owned = false;
40311         LDKLightningError ret_var = LightningError_clone(&orig_conv);
40312         int64_t ret_ref = 0;
40313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40314         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40315         return ret_ref;
40316 }
40317
40318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40319         LDKCommitmentUpdate this_obj_conv;
40320         this_obj_conv.inner = untag_ptr(this_obj);
40321         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40323         CommitmentUpdate_free(this_obj_conv);
40324 }
40325
40326 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40327         LDKCommitmentUpdate this_ptr_conv;
40328         this_ptr_conv.inner = untag_ptr(this_ptr);
40329         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40331         this_ptr_conv.is_owned = false;
40332         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
40333         int64_tArray ret_arr = NULL;
40334         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40335         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40336         for (size_t p = 0; p < ret_var.datalen; p++) {
40337                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
40338                 int64_t ret_conv_15_ref = 0;
40339                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
40340                 ret_conv_15_ref = tag_ptr(ret_conv_15_var.inner, ret_conv_15_var.is_owned);
40341                 ret_arr_ptr[p] = ret_conv_15_ref;
40342         }
40343         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40344         FREE(ret_var.data);
40345         return ret_arr;
40346 }
40347
40348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40349         LDKCommitmentUpdate this_ptr_conv;
40350         this_ptr_conv.inner = untag_ptr(this_ptr);
40351         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40353         this_ptr_conv.is_owned = false;
40354         LDKCVec_UpdateAddHTLCZ val_constr;
40355         val_constr.datalen = (*env)->GetArrayLength(env, val);
40356         if (val_constr.datalen > 0)
40357                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
40358         else
40359                 val_constr.data = NULL;
40360         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40361         for (size_t p = 0; p < val_constr.datalen; p++) {
40362                 int64_t val_conv_15 = val_vals[p];
40363                 LDKUpdateAddHTLC val_conv_15_conv;
40364                 val_conv_15_conv.inner = untag_ptr(val_conv_15);
40365                 val_conv_15_conv.is_owned = ptr_is_owned(val_conv_15);
40366                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
40367                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
40368                 val_constr.data[p] = val_conv_15_conv;
40369         }
40370         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40371         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
40372 }
40373
40374 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40375         LDKCommitmentUpdate this_ptr_conv;
40376         this_ptr_conv.inner = untag_ptr(this_ptr);
40377         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40379         this_ptr_conv.is_owned = false;
40380         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
40381         int64_tArray ret_arr = NULL;
40382         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40383         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40384         for (size_t t = 0; t < ret_var.datalen; t++) {
40385                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
40386                 int64_t ret_conv_19_ref = 0;
40387                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
40388                 ret_conv_19_ref = tag_ptr(ret_conv_19_var.inner, ret_conv_19_var.is_owned);
40389                 ret_arr_ptr[t] = ret_conv_19_ref;
40390         }
40391         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40392         FREE(ret_var.data);
40393         return ret_arr;
40394 }
40395
40396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40397         LDKCommitmentUpdate this_ptr_conv;
40398         this_ptr_conv.inner = untag_ptr(this_ptr);
40399         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40401         this_ptr_conv.is_owned = false;
40402         LDKCVec_UpdateFulfillHTLCZ val_constr;
40403         val_constr.datalen = (*env)->GetArrayLength(env, val);
40404         if (val_constr.datalen > 0)
40405                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
40406         else
40407                 val_constr.data = NULL;
40408         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40409         for (size_t t = 0; t < val_constr.datalen; t++) {
40410                 int64_t val_conv_19 = val_vals[t];
40411                 LDKUpdateFulfillHTLC val_conv_19_conv;
40412                 val_conv_19_conv.inner = untag_ptr(val_conv_19);
40413                 val_conv_19_conv.is_owned = ptr_is_owned(val_conv_19);
40414                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
40415                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
40416                 val_constr.data[t] = val_conv_19_conv;
40417         }
40418         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40419         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
40420 }
40421
40422 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40423         LDKCommitmentUpdate this_ptr_conv;
40424         this_ptr_conv.inner = untag_ptr(this_ptr);
40425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40427         this_ptr_conv.is_owned = false;
40428         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
40429         int64_tArray ret_arr = NULL;
40430         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40431         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40432         for (size_t q = 0; q < ret_var.datalen; q++) {
40433                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
40434                 int64_t ret_conv_16_ref = 0;
40435                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
40436                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
40437                 ret_arr_ptr[q] = ret_conv_16_ref;
40438         }
40439         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40440         FREE(ret_var.data);
40441         return ret_arr;
40442 }
40443
40444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40445         LDKCommitmentUpdate this_ptr_conv;
40446         this_ptr_conv.inner = untag_ptr(this_ptr);
40447         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40449         this_ptr_conv.is_owned = false;
40450         LDKCVec_UpdateFailHTLCZ val_constr;
40451         val_constr.datalen = (*env)->GetArrayLength(env, val);
40452         if (val_constr.datalen > 0)
40453                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
40454         else
40455                 val_constr.data = NULL;
40456         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40457         for (size_t q = 0; q < val_constr.datalen; q++) {
40458                 int64_t val_conv_16 = val_vals[q];
40459                 LDKUpdateFailHTLC val_conv_16_conv;
40460                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
40461                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
40462                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
40463                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
40464                 val_constr.data[q] = val_conv_16_conv;
40465         }
40466         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40467         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
40468 }
40469
40470 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40471         LDKCommitmentUpdate this_ptr_conv;
40472         this_ptr_conv.inner = untag_ptr(this_ptr);
40473         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40475         this_ptr_conv.is_owned = false;
40476         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
40477         int64_tArray ret_arr = NULL;
40478         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40479         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40480         for (size_t z = 0; z < ret_var.datalen; z++) {
40481                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
40482                 int64_t ret_conv_25_ref = 0;
40483                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
40484                 ret_conv_25_ref = tag_ptr(ret_conv_25_var.inner, ret_conv_25_var.is_owned);
40485                 ret_arr_ptr[z] = ret_conv_25_ref;
40486         }
40487         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40488         FREE(ret_var.data);
40489         return ret_arr;
40490 }
40491
40492 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) {
40493         LDKCommitmentUpdate this_ptr_conv;
40494         this_ptr_conv.inner = untag_ptr(this_ptr);
40495         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40497         this_ptr_conv.is_owned = false;
40498         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
40499         val_constr.datalen = (*env)->GetArrayLength(env, val);
40500         if (val_constr.datalen > 0)
40501                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
40502         else
40503                 val_constr.data = NULL;
40504         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40505         for (size_t z = 0; z < val_constr.datalen; z++) {
40506                 int64_t val_conv_25 = val_vals[z];
40507                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
40508                 val_conv_25_conv.inner = untag_ptr(val_conv_25);
40509                 val_conv_25_conv.is_owned = ptr_is_owned(val_conv_25);
40510                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
40511                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
40512                 val_constr.data[z] = val_conv_25_conv;
40513         }
40514         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40515         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
40516 }
40517
40518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
40519         LDKCommitmentUpdate this_ptr_conv;
40520         this_ptr_conv.inner = untag_ptr(this_ptr);
40521         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40523         this_ptr_conv.is_owned = false;
40524         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
40525         int64_t ret_ref = 0;
40526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40527         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40528         return ret_ref;
40529 }
40530
40531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40532         LDKCommitmentUpdate this_ptr_conv;
40533         this_ptr_conv.inner = untag_ptr(this_ptr);
40534         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40536         this_ptr_conv.is_owned = false;
40537         LDKUpdateFee val_conv;
40538         val_conv.inner = untag_ptr(val);
40539         val_conv.is_owned = ptr_is_owned(val);
40540         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40541         val_conv = UpdateFee_clone(&val_conv);
40542         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
40543 }
40544
40545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
40546         LDKCommitmentUpdate this_ptr_conv;
40547         this_ptr_conv.inner = untag_ptr(this_ptr);
40548         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40550         this_ptr_conv.is_owned = false;
40551         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
40552         int64_t ret_ref = 0;
40553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40554         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40555         return ret_ref;
40556 }
40557
40558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40559         LDKCommitmentUpdate this_ptr_conv;
40560         this_ptr_conv.inner = untag_ptr(this_ptr);
40561         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40563         this_ptr_conv.is_owned = false;
40564         LDKCommitmentSigned val_conv;
40565         val_conv.inner = untag_ptr(val);
40566         val_conv.is_owned = ptr_is_owned(val);
40567         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40568         val_conv = CommitmentSigned_clone(&val_conv);
40569         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
40570 }
40571
40572 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) {
40573         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
40574         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
40575         if (update_add_htlcs_arg_constr.datalen > 0)
40576                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
40577         else
40578                 update_add_htlcs_arg_constr.data = NULL;
40579         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
40580         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
40581                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
40582                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
40583                 update_add_htlcs_arg_conv_15_conv.inner = untag_ptr(update_add_htlcs_arg_conv_15);
40584                 update_add_htlcs_arg_conv_15_conv.is_owned = ptr_is_owned(update_add_htlcs_arg_conv_15);
40585                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
40586                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
40587                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
40588         }
40589         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
40590         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
40591         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
40592         if (update_fulfill_htlcs_arg_constr.datalen > 0)
40593                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
40594         else
40595                 update_fulfill_htlcs_arg_constr.data = NULL;
40596         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
40597         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
40598                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
40599                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
40600                 update_fulfill_htlcs_arg_conv_19_conv.inner = untag_ptr(update_fulfill_htlcs_arg_conv_19);
40601                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = ptr_is_owned(update_fulfill_htlcs_arg_conv_19);
40602                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
40603                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
40604                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
40605         }
40606         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
40607         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
40608         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
40609         if (update_fail_htlcs_arg_constr.datalen > 0)
40610                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
40611         else
40612                 update_fail_htlcs_arg_constr.data = NULL;
40613         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
40614         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
40615                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
40616                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
40617                 update_fail_htlcs_arg_conv_16_conv.inner = untag_ptr(update_fail_htlcs_arg_conv_16);
40618                 update_fail_htlcs_arg_conv_16_conv.is_owned = ptr_is_owned(update_fail_htlcs_arg_conv_16);
40619                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
40620                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
40621                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
40622         }
40623         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
40624         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
40625         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
40626         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
40627                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
40628         else
40629                 update_fail_malformed_htlcs_arg_constr.data = NULL;
40630         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
40631         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
40632                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
40633                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
40634                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = untag_ptr(update_fail_malformed_htlcs_arg_conv_25);
40635                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = ptr_is_owned(update_fail_malformed_htlcs_arg_conv_25);
40636                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
40637                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
40638                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
40639         }
40640         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
40641         LDKUpdateFee update_fee_arg_conv;
40642         update_fee_arg_conv.inner = untag_ptr(update_fee_arg);
40643         update_fee_arg_conv.is_owned = ptr_is_owned(update_fee_arg);
40644         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
40645         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
40646         LDKCommitmentSigned commitment_signed_arg_conv;
40647         commitment_signed_arg_conv.inner = untag_ptr(commitment_signed_arg);
40648         commitment_signed_arg_conv.is_owned = ptr_is_owned(commitment_signed_arg);
40649         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
40650         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
40651         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);
40652         int64_t ret_ref = 0;
40653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40654         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40655         return ret_ref;
40656 }
40657
40658 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
40659         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
40660         int64_t ret_ref = 0;
40661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40662         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40663         return ret_ref;
40664 }
40665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40666         LDKCommitmentUpdate arg_conv;
40667         arg_conv.inner = untag_ptr(arg);
40668         arg_conv.is_owned = ptr_is_owned(arg);
40669         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40670         arg_conv.is_owned = false;
40671         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
40672         return ret_conv;
40673 }
40674
40675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40676         LDKCommitmentUpdate orig_conv;
40677         orig_conv.inner = untag_ptr(orig);
40678         orig_conv.is_owned = ptr_is_owned(orig);
40679         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40680         orig_conv.is_owned = false;
40681         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
40682         int64_t ret_ref = 0;
40683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40684         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40685         return ret_ref;
40686 }
40687
40688 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40689         LDKCommitmentUpdate a_conv;
40690         a_conv.inner = untag_ptr(a);
40691         a_conv.is_owned = ptr_is_owned(a);
40692         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40693         a_conv.is_owned = false;
40694         LDKCommitmentUpdate b_conv;
40695         b_conv.inner = untag_ptr(b);
40696         b_conv.is_owned = ptr_is_owned(b);
40697         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40698         b_conv.is_owned = false;
40699         jboolean ret_conv = CommitmentUpdate_eq(&a_conv, &b_conv);
40700         return ret_conv;
40701 }
40702
40703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40704         if (!ptr_is_owned(this_ptr)) return;
40705         void* this_ptr_ptr = untag_ptr(this_ptr);
40706         CHECK_ACCESS(this_ptr_ptr);
40707         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
40708         FREE(untag_ptr(this_ptr));
40709         ChannelMessageHandler_free(this_ptr_conv);
40710 }
40711
40712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40713         if (!ptr_is_owned(this_ptr)) return;
40714         void* this_ptr_ptr = untag_ptr(this_ptr);
40715         CHECK_ACCESS(this_ptr_ptr);
40716         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
40717         FREE(untag_ptr(this_ptr));
40718         RoutingMessageHandler_free(this_ptr_conv);
40719 }
40720
40721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40722         if (!ptr_is_owned(this_ptr)) return;
40723         void* this_ptr_ptr = untag_ptr(this_ptr);
40724         CHECK_ACCESS(this_ptr_ptr);
40725         LDKOnionMessageHandler this_ptr_conv = *(LDKOnionMessageHandler*)(this_ptr_ptr);
40726         FREE(untag_ptr(this_ptr));
40727         OnionMessageHandler_free(this_ptr_conv);
40728 }
40729
40730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
40731         LDKAcceptChannel obj_conv;
40732         obj_conv.inner = untag_ptr(obj);
40733         obj_conv.is_owned = ptr_is_owned(obj);
40734         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40735         obj_conv.is_owned = false;
40736         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
40737         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40738         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40739         CVec_u8Z_free(ret_var);
40740         return ret_arr;
40741 }
40742
40743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40744         LDKu8slice ser_ref;
40745         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40746         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40747         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
40748         *ret_conv = AcceptChannel_read(ser_ref);
40749         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40750         return tag_ptr(ret_conv, true);
40751 }
40752
40753 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40754         LDKAnnouncementSignatures obj_conv;
40755         obj_conv.inner = untag_ptr(obj);
40756         obj_conv.is_owned = ptr_is_owned(obj);
40757         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40758         obj_conv.is_owned = false;
40759         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
40760         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40761         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40762         CVec_u8Z_free(ret_var);
40763         return ret_arr;
40764 }
40765
40766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40767         LDKu8slice ser_ref;
40768         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40769         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40770         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
40771         *ret_conv = AnnouncementSignatures_read(ser_ref);
40772         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40773         return tag_ptr(ret_conv, true);
40774 }
40775
40776 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
40777         LDKChannelReestablish obj_conv;
40778         obj_conv.inner = untag_ptr(obj);
40779         obj_conv.is_owned = ptr_is_owned(obj);
40780         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40781         obj_conv.is_owned = false;
40782         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
40783         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40784         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40785         CVec_u8Z_free(ret_var);
40786         return ret_arr;
40787 }
40788
40789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40790         LDKu8slice ser_ref;
40791         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40792         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40793         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
40794         *ret_conv = ChannelReestablish_read(ser_ref);
40795         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40796         return tag_ptr(ret_conv, true);
40797 }
40798
40799 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40800         LDKClosingSigned obj_conv;
40801         obj_conv.inner = untag_ptr(obj);
40802         obj_conv.is_owned = ptr_is_owned(obj);
40803         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40804         obj_conv.is_owned = false;
40805         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
40806         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40807         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40808         CVec_u8Z_free(ret_var);
40809         return ret_arr;
40810 }
40811
40812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40813         LDKu8slice ser_ref;
40814         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40815         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40816         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
40817         *ret_conv = ClosingSigned_read(ser_ref);
40818         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40819         return tag_ptr(ret_conv, true);
40820 }
40821
40822 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
40823         LDKClosingSignedFeeRange obj_conv;
40824         obj_conv.inner = untag_ptr(obj);
40825         obj_conv.is_owned = ptr_is_owned(obj);
40826         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40827         obj_conv.is_owned = false;
40828         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
40829         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40830         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40831         CVec_u8Z_free(ret_var);
40832         return ret_arr;
40833 }
40834
40835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40836         LDKu8slice ser_ref;
40837         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40838         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40839         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
40840         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
40841         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40842         return tag_ptr(ret_conv, true);
40843 }
40844
40845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40846         LDKCommitmentSigned obj_conv;
40847         obj_conv.inner = untag_ptr(obj);
40848         obj_conv.is_owned = ptr_is_owned(obj);
40849         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40850         obj_conv.is_owned = false;
40851         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
40852         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40853         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40854         CVec_u8Z_free(ret_var);
40855         return ret_arr;
40856 }
40857
40858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40859         LDKu8slice ser_ref;
40860         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40861         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40862         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
40863         *ret_conv = CommitmentSigned_read(ser_ref);
40864         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40865         return tag_ptr(ret_conv, true);
40866 }
40867
40868 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
40869         LDKFundingCreated obj_conv;
40870         obj_conv.inner = untag_ptr(obj);
40871         obj_conv.is_owned = ptr_is_owned(obj);
40872         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40873         obj_conv.is_owned = false;
40874         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
40875         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40876         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40877         CVec_u8Z_free(ret_var);
40878         return ret_arr;
40879 }
40880
40881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40882         LDKu8slice ser_ref;
40883         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40884         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40885         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
40886         *ret_conv = FundingCreated_read(ser_ref);
40887         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40888         return tag_ptr(ret_conv, true);
40889 }
40890
40891 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40892         LDKFundingSigned obj_conv;
40893         obj_conv.inner = untag_ptr(obj);
40894         obj_conv.is_owned = ptr_is_owned(obj);
40895         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40896         obj_conv.is_owned = false;
40897         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
40898         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40899         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40900         CVec_u8Z_free(ret_var);
40901         return ret_arr;
40902 }
40903
40904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40905         LDKu8slice ser_ref;
40906         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40907         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40908         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
40909         *ret_conv = FundingSigned_read(ser_ref);
40910         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40911         return tag_ptr(ret_conv, true);
40912 }
40913
40914 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
40915         LDKChannelReady obj_conv;
40916         obj_conv.inner = untag_ptr(obj);
40917         obj_conv.is_owned = ptr_is_owned(obj);
40918         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40919         obj_conv.is_owned = false;
40920         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
40921         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40922         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40923         CVec_u8Z_free(ret_var);
40924         return ret_arr;
40925 }
40926
40927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40928         LDKu8slice ser_ref;
40929         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40930         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40931         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
40932         *ret_conv = ChannelReady_read(ser_ref);
40933         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40934         return tag_ptr(ret_conv, true);
40935 }
40936
40937 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
40938         LDKInit obj_conv;
40939         obj_conv.inner = untag_ptr(obj);
40940         obj_conv.is_owned = ptr_is_owned(obj);
40941         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40942         obj_conv.is_owned = false;
40943         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
40944         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40945         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40946         CVec_u8Z_free(ret_var);
40947         return ret_arr;
40948 }
40949
40950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40951         LDKu8slice ser_ref;
40952         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40953         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40954         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
40955         *ret_conv = Init_read(ser_ref);
40956         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40957         return tag_ptr(ret_conv, true);
40958 }
40959
40960 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
40961         LDKOpenChannel obj_conv;
40962         obj_conv.inner = untag_ptr(obj);
40963         obj_conv.is_owned = ptr_is_owned(obj);
40964         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40965         obj_conv.is_owned = false;
40966         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
40967         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40968         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40969         CVec_u8Z_free(ret_var);
40970         return ret_arr;
40971 }
40972
40973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40974         LDKu8slice ser_ref;
40975         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40976         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40977         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
40978         *ret_conv = OpenChannel_read(ser_ref);
40979         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40980         return tag_ptr(ret_conv, true);
40981 }
40982
40983 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
40984         LDKRevokeAndACK obj_conv;
40985         obj_conv.inner = untag_ptr(obj);
40986         obj_conv.is_owned = ptr_is_owned(obj);
40987         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40988         obj_conv.is_owned = false;
40989         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
40990         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40991         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40992         CVec_u8Z_free(ret_var);
40993         return ret_arr;
40994 }
40995
40996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40997         LDKu8slice ser_ref;
40998         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40999         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41000         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
41001         *ret_conv = RevokeAndACK_read(ser_ref);
41002         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41003         return tag_ptr(ret_conv, true);
41004 }
41005
41006 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
41007         LDKShutdown obj_conv;
41008         obj_conv.inner = untag_ptr(obj);
41009         obj_conv.is_owned = ptr_is_owned(obj);
41010         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41011         obj_conv.is_owned = false;
41012         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
41013         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41014         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41015         CVec_u8Z_free(ret_var);
41016         return ret_arr;
41017 }
41018
41019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41020         LDKu8slice ser_ref;
41021         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41022         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41023         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
41024         *ret_conv = Shutdown_read(ser_ref);
41025         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41026         return tag_ptr(ret_conv, true);
41027 }
41028
41029 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41030         LDKUpdateFailHTLC obj_conv;
41031         obj_conv.inner = untag_ptr(obj);
41032         obj_conv.is_owned = ptr_is_owned(obj);
41033         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41034         obj_conv.is_owned = false;
41035         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
41036         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41037         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41038         CVec_u8Z_free(ret_var);
41039         return ret_arr;
41040 }
41041
41042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41043         LDKu8slice ser_ref;
41044         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41045         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41046         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
41047         *ret_conv = UpdateFailHTLC_read(ser_ref);
41048         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41049         return tag_ptr(ret_conv, true);
41050 }
41051
41052 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41053         LDKUpdateFailMalformedHTLC obj_conv;
41054         obj_conv.inner = untag_ptr(obj);
41055         obj_conv.is_owned = ptr_is_owned(obj);
41056         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41057         obj_conv.is_owned = false;
41058         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
41059         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41060         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41061         CVec_u8Z_free(ret_var);
41062         return ret_arr;
41063 }
41064
41065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41066         LDKu8slice ser_ref;
41067         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41068         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41069         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
41070         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
41071         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41072         return tag_ptr(ret_conv, true);
41073 }
41074
41075 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
41076         LDKUpdateFee obj_conv;
41077         obj_conv.inner = untag_ptr(obj);
41078         obj_conv.is_owned = ptr_is_owned(obj);
41079         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41080         obj_conv.is_owned = false;
41081         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
41082         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41083         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41084         CVec_u8Z_free(ret_var);
41085         return ret_arr;
41086 }
41087
41088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41089         LDKu8slice ser_ref;
41090         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41091         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41092         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
41093         *ret_conv = UpdateFee_read(ser_ref);
41094         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41095         return tag_ptr(ret_conv, true);
41096 }
41097
41098 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41099         LDKUpdateFulfillHTLC obj_conv;
41100         obj_conv.inner = untag_ptr(obj);
41101         obj_conv.is_owned = ptr_is_owned(obj);
41102         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41103         obj_conv.is_owned = false;
41104         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
41105         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41106         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41107         CVec_u8Z_free(ret_var);
41108         return ret_arr;
41109 }
41110
41111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41112         LDKu8slice ser_ref;
41113         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41114         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41115         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
41116         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
41117         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41118         return tag_ptr(ret_conv, true);
41119 }
41120
41121 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41122         LDKUpdateAddHTLC obj_conv;
41123         obj_conv.inner = untag_ptr(obj);
41124         obj_conv.is_owned = ptr_is_owned(obj);
41125         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41126         obj_conv.is_owned = false;
41127         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
41128         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41129         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41130         CVec_u8Z_free(ret_var);
41131         return ret_arr;
41132 }
41133
41134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41135         LDKu8slice ser_ref;
41136         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41137         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41138         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
41139         *ret_conv = UpdateAddHTLC_read(ser_ref);
41140         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41141         return tag_ptr(ret_conv, true);
41142 }
41143
41144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41145         LDKu8slice ser_ref;
41146         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41147         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41148         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
41149         *ret_conv = OnionMessage_read(ser_ref);
41150         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41151         return tag_ptr(ret_conv, true);
41152 }
41153
41154 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
41155         LDKOnionMessage obj_conv;
41156         obj_conv.inner = untag_ptr(obj);
41157         obj_conv.is_owned = ptr_is_owned(obj);
41158         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41159         obj_conv.is_owned = false;
41160         LDKCVec_u8Z ret_var = OnionMessage_write(&obj_conv);
41161         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41162         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41163         CVec_u8Z_free(ret_var);
41164         return ret_arr;
41165 }
41166
41167 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
41168         LDKPing obj_conv;
41169         obj_conv.inner = untag_ptr(obj);
41170         obj_conv.is_owned = ptr_is_owned(obj);
41171         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41172         obj_conv.is_owned = false;
41173         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
41174         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41175         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41176         CVec_u8Z_free(ret_var);
41177         return ret_arr;
41178 }
41179
41180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41181         LDKu8slice ser_ref;
41182         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41183         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41184         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
41185         *ret_conv = Ping_read(ser_ref);
41186         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41187         return tag_ptr(ret_conv, true);
41188 }
41189
41190 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
41191         LDKPong obj_conv;
41192         obj_conv.inner = untag_ptr(obj);
41193         obj_conv.is_owned = ptr_is_owned(obj);
41194         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41195         obj_conv.is_owned = false;
41196         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
41197         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41198         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41199         CVec_u8Z_free(ret_var);
41200         return ret_arr;
41201 }
41202
41203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41204         LDKu8slice ser_ref;
41205         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41206         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41207         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
41208         *ret_conv = Pong_read(ser_ref);
41209         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41210         return tag_ptr(ret_conv, true);
41211 }
41212
41213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41214         LDKUnsignedChannelAnnouncement obj_conv;
41215         obj_conv.inner = untag_ptr(obj);
41216         obj_conv.is_owned = ptr_is_owned(obj);
41217         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41218         obj_conv.is_owned = false;
41219         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
41220         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41221         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41222         CVec_u8Z_free(ret_var);
41223         return ret_arr;
41224 }
41225
41226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41227         LDKu8slice ser_ref;
41228         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41229         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41230         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
41231         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
41232         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41233         return tag_ptr(ret_conv, true);
41234 }
41235
41236 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41237         LDKChannelAnnouncement obj_conv;
41238         obj_conv.inner = untag_ptr(obj);
41239         obj_conv.is_owned = ptr_is_owned(obj);
41240         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41241         obj_conv.is_owned = false;
41242         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
41243         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41244         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41245         CVec_u8Z_free(ret_var);
41246         return ret_arr;
41247 }
41248
41249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41250         LDKu8slice ser_ref;
41251         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41252         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41253         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
41254         *ret_conv = ChannelAnnouncement_read(ser_ref);
41255         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41256         return tag_ptr(ret_conv, true);
41257 }
41258
41259 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
41260         LDKUnsignedChannelUpdate obj_conv;
41261         obj_conv.inner = untag_ptr(obj);
41262         obj_conv.is_owned = ptr_is_owned(obj);
41263         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41264         obj_conv.is_owned = false;
41265         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
41266         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41267         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41268         CVec_u8Z_free(ret_var);
41269         return ret_arr;
41270 }
41271
41272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41273         LDKu8slice ser_ref;
41274         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41275         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41276         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
41277         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
41278         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41279         return tag_ptr(ret_conv, true);
41280 }
41281
41282 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
41283         LDKChannelUpdate obj_conv;
41284         obj_conv.inner = untag_ptr(obj);
41285         obj_conv.is_owned = ptr_is_owned(obj);
41286         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41287         obj_conv.is_owned = false;
41288         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
41289         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41290         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41291         CVec_u8Z_free(ret_var);
41292         return ret_arr;
41293 }
41294
41295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41296         LDKu8slice ser_ref;
41297         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41298         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41299         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
41300         *ret_conv = ChannelUpdate_read(ser_ref);
41301         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41302         return tag_ptr(ret_conv, true);
41303 }
41304
41305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
41306         LDKErrorMessage obj_conv;
41307         obj_conv.inner = untag_ptr(obj);
41308         obj_conv.is_owned = ptr_is_owned(obj);
41309         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41310         obj_conv.is_owned = false;
41311         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
41312         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41313         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41314         CVec_u8Z_free(ret_var);
41315         return ret_arr;
41316 }
41317
41318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41319         LDKu8slice ser_ref;
41320         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41321         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41322         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
41323         *ret_conv = ErrorMessage_read(ser_ref);
41324         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41325         return tag_ptr(ret_conv, true);
41326 }
41327
41328 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
41329         LDKWarningMessage obj_conv;
41330         obj_conv.inner = untag_ptr(obj);
41331         obj_conv.is_owned = ptr_is_owned(obj);
41332         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41333         obj_conv.is_owned = false;
41334         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
41335         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41336         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41337         CVec_u8Z_free(ret_var);
41338         return ret_arr;
41339 }
41340
41341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41342         LDKu8slice ser_ref;
41343         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41344         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41345         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
41346         *ret_conv = WarningMessage_read(ser_ref);
41347         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41348         return tag_ptr(ret_conv, true);
41349 }
41350
41351 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41352         LDKUnsignedNodeAnnouncement obj_conv;
41353         obj_conv.inner = untag_ptr(obj);
41354         obj_conv.is_owned = ptr_is_owned(obj);
41355         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41356         obj_conv.is_owned = false;
41357         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
41358         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41359         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41360         CVec_u8Z_free(ret_var);
41361         return ret_arr;
41362 }
41363
41364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41365         LDKu8slice ser_ref;
41366         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41367         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41368         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
41369         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
41370         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41371         return tag_ptr(ret_conv, true);
41372 }
41373
41374 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41375         LDKNodeAnnouncement obj_conv;
41376         obj_conv.inner = untag_ptr(obj);
41377         obj_conv.is_owned = ptr_is_owned(obj);
41378         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41379         obj_conv.is_owned = false;
41380         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
41381         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41382         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41383         CVec_u8Z_free(ret_var);
41384         return ret_arr;
41385 }
41386
41387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41388         LDKu8slice ser_ref;
41389         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41390         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41391         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
41392         *ret_conv = NodeAnnouncement_read(ser_ref);
41393         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41394         return tag_ptr(ret_conv, true);
41395 }
41396
41397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41398         LDKu8slice ser_ref;
41399         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41400         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41401         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
41402         *ret_conv = QueryShortChannelIds_read(ser_ref);
41403         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41404         return tag_ptr(ret_conv, true);
41405 }
41406
41407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
41408         LDKQueryShortChannelIds obj_conv;
41409         obj_conv.inner = untag_ptr(obj);
41410         obj_conv.is_owned = ptr_is_owned(obj);
41411         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41412         obj_conv.is_owned = false;
41413         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
41414         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41415         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41416         CVec_u8Z_free(ret_var);
41417         return ret_arr;
41418 }
41419
41420 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
41421         LDKReplyShortChannelIdsEnd obj_conv;
41422         obj_conv.inner = untag_ptr(obj);
41423         obj_conv.is_owned = ptr_is_owned(obj);
41424         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41425         obj_conv.is_owned = false;
41426         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
41427         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41428         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41429         CVec_u8Z_free(ret_var);
41430         return ret_arr;
41431 }
41432
41433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41434         LDKu8slice ser_ref;
41435         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41436         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41437         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
41438         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
41439         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41440         return tag_ptr(ret_conv, true);
41441 }
41442
41443 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
41444         LDKQueryChannelRange this_arg_conv;
41445         this_arg_conv.inner = untag_ptr(this_arg);
41446         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41448         this_arg_conv.is_owned = false;
41449         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
41450         return ret_conv;
41451 }
41452
41453 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
41454         LDKQueryChannelRange obj_conv;
41455         obj_conv.inner = untag_ptr(obj);
41456         obj_conv.is_owned = ptr_is_owned(obj);
41457         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41458         obj_conv.is_owned = false;
41459         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
41460         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41461         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41462         CVec_u8Z_free(ret_var);
41463         return ret_arr;
41464 }
41465
41466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41467         LDKu8slice ser_ref;
41468         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41469         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41470         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
41471         *ret_conv = QueryChannelRange_read(ser_ref);
41472         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41473         return tag_ptr(ret_conv, true);
41474 }
41475
41476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41477         LDKu8slice ser_ref;
41478         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41479         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41480         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
41481         *ret_conv = ReplyChannelRange_read(ser_ref);
41482         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41483         return tag_ptr(ret_conv, true);
41484 }
41485
41486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
41487         LDKReplyChannelRange obj_conv;
41488         obj_conv.inner = untag_ptr(obj);
41489         obj_conv.is_owned = ptr_is_owned(obj);
41490         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41491         obj_conv.is_owned = false;
41492         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
41493         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41494         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41495         CVec_u8Z_free(ret_var);
41496         return ret_arr;
41497 }
41498
41499 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
41500         LDKGossipTimestampFilter obj_conv;
41501         obj_conv.inner = untag_ptr(obj);
41502         obj_conv.is_owned = ptr_is_owned(obj);
41503         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41504         obj_conv.is_owned = false;
41505         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
41506         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41507         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41508         CVec_u8Z_free(ret_var);
41509         return ret_arr;
41510 }
41511
41512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41513         LDKu8slice ser_ref;
41514         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41515         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41516         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
41517         *ret_conv = GossipTimestampFilter_read(ser_ref);
41518         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41519         return tag_ptr(ret_conv, true);
41520 }
41521
41522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41523         if (!ptr_is_owned(this_ptr)) return;
41524         void* this_ptr_ptr = untag_ptr(this_ptr);
41525         CHECK_ACCESS(this_ptr_ptr);
41526         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
41527         FREE(untag_ptr(this_ptr));
41528         CustomMessageHandler_free(this_ptr_conv);
41529 }
41530
41531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41532         LDKIgnoringMessageHandler this_obj_conv;
41533         this_obj_conv.inner = untag_ptr(this_obj);
41534         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41536         IgnoringMessageHandler_free(this_obj_conv);
41537 }
41538
41539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
41540         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
41541         int64_t ret_ref = 0;
41542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41543         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41544         return ret_ref;
41545 }
41546
41547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41548         LDKIgnoringMessageHandler this_arg_conv;
41549         this_arg_conv.inner = untag_ptr(this_arg);
41550         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41552         this_arg_conv.is_owned = false;
41553         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
41554         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
41555         return tag_ptr(ret_ret, true);
41556 }
41557
41558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41559         LDKIgnoringMessageHandler this_arg_conv;
41560         this_arg_conv.inner = untag_ptr(this_arg);
41561         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41563         this_arg_conv.is_owned = false;
41564         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
41565         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
41566         return tag_ptr(ret_ret, true);
41567 }
41568
41569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41570         LDKIgnoringMessageHandler this_arg_conv;
41571         this_arg_conv.inner = untag_ptr(this_arg);
41572         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41574         this_arg_conv.is_owned = false;
41575         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
41576         *ret_ret = IgnoringMessageHandler_as_OnionMessageProvider(&this_arg_conv);
41577         return tag_ptr(ret_ret, true);
41578 }
41579
41580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41581         LDKIgnoringMessageHandler this_arg_conv;
41582         this_arg_conv.inner = untag_ptr(this_arg);
41583         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41585         this_arg_conv.is_owned = false;
41586         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
41587         *ret_ret = IgnoringMessageHandler_as_OnionMessageHandler(&this_arg_conv);
41588         return tag_ptr(ret_ret, true);
41589 }
41590
41591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomOnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41592         LDKIgnoringMessageHandler this_arg_conv;
41593         this_arg_conv.inner = untag_ptr(this_arg);
41594         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41596         this_arg_conv.is_owned = false;
41597         LDKCustomOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
41598         *ret_ret = IgnoringMessageHandler_as_CustomOnionMessageHandler(&this_arg_conv);
41599         return tag_ptr(ret_ret, true);
41600 }
41601
41602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
41603         LDKIgnoringMessageHandler this_arg_conv;
41604         this_arg_conv.inner = untag_ptr(this_arg);
41605         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41607         this_arg_conv.is_owned = false;
41608         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
41609         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
41610         return tag_ptr(ret_ret, true);
41611 }
41612
41613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41614         LDKIgnoringMessageHandler this_arg_conv;
41615         this_arg_conv.inner = untag_ptr(this_arg);
41616         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41618         this_arg_conv.is_owned = false;
41619         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
41620         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
41621         return tag_ptr(ret_ret, true);
41622 }
41623
41624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41625         LDKErroringMessageHandler this_obj_conv;
41626         this_obj_conv.inner = untag_ptr(this_obj);
41627         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41629         ErroringMessageHandler_free(this_obj_conv);
41630 }
41631
41632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
41633         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
41634         int64_t ret_ref = 0;
41635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41636         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41637         return ret_ref;
41638 }
41639
41640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41641         LDKErroringMessageHandler this_arg_conv;
41642         this_arg_conv.inner = untag_ptr(this_arg);
41643         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41645         this_arg_conv.is_owned = false;
41646         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
41647         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
41648         return tag_ptr(ret_ret, true);
41649 }
41650
41651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41652         LDKErroringMessageHandler this_arg_conv;
41653         this_arg_conv.inner = untag_ptr(this_arg);
41654         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41656         this_arg_conv.is_owned = false;
41657         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
41658         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
41659         return tag_ptr(ret_ret, true);
41660 }
41661
41662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41663         LDKMessageHandler this_obj_conv;
41664         this_obj_conv.inner = untag_ptr(this_obj);
41665         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41667         MessageHandler_free(this_obj_conv);
41668 }
41669
41670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
41671         LDKMessageHandler this_ptr_conv;
41672         this_ptr_conv.inner = untag_ptr(this_ptr);
41673         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41675         this_ptr_conv.is_owned = false;
41676         // WARNING: This object doesn't live past this scope, needs clone!
41677         int64_t ret_ret = tag_ptr(MessageHandler_get_chan_handler(&this_ptr_conv), false);
41678         return ret_ret;
41679 }
41680
41681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41682         LDKMessageHandler this_ptr_conv;
41683         this_ptr_conv.inner = untag_ptr(this_ptr);
41684         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41686         this_ptr_conv.is_owned = false;
41687         void* val_ptr = untag_ptr(val);
41688         CHECK_ACCESS(val_ptr);
41689         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
41690         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
41691                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41692                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
41693         }
41694         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
41695 }
41696
41697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
41698         LDKMessageHandler this_ptr_conv;
41699         this_ptr_conv.inner = untag_ptr(this_ptr);
41700         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41702         this_ptr_conv.is_owned = false;
41703         // WARNING: This object doesn't live past this scope, needs clone!
41704         int64_t ret_ret = tag_ptr(MessageHandler_get_route_handler(&this_ptr_conv), false);
41705         return ret_ret;
41706 }
41707
41708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41709         LDKMessageHandler this_ptr_conv;
41710         this_ptr_conv.inner = untag_ptr(this_ptr);
41711         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41713         this_ptr_conv.is_owned = false;
41714         void* val_ptr = untag_ptr(val);
41715         CHECK_ACCESS(val_ptr);
41716         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
41717         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
41718                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41719                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
41720         }
41721         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
41722 }
41723
41724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
41725         LDKMessageHandler this_ptr_conv;
41726         this_ptr_conv.inner = untag_ptr(this_ptr);
41727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41729         this_ptr_conv.is_owned = false;
41730         // WARNING: This object doesn't live past this scope, needs clone!
41731         int64_t ret_ret = tag_ptr(MessageHandler_get_onion_message_handler(&this_ptr_conv), false);
41732         return ret_ret;
41733 }
41734
41735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41736         LDKMessageHandler this_ptr_conv;
41737         this_ptr_conv.inner = untag_ptr(this_ptr);
41738         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41740         this_ptr_conv.is_owned = false;
41741         void* val_ptr = untag_ptr(val);
41742         CHECK_ACCESS(val_ptr);
41743         LDKOnionMessageHandler val_conv = *(LDKOnionMessageHandler*)(val_ptr);
41744         if (val_conv.free == LDKOnionMessageHandler_JCalls_free) {
41745                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41746                 LDKOnionMessageHandler_JCalls_cloned(&val_conv);
41747         }
41748         MessageHandler_set_onion_message_handler(&this_ptr_conv, val_conv);
41749 }
41750
41751 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) {
41752         void* chan_handler_arg_ptr = untag_ptr(chan_handler_arg);
41753         CHECK_ACCESS(chan_handler_arg_ptr);
41754         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
41755         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
41756                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41757                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
41758         }
41759         void* route_handler_arg_ptr = untag_ptr(route_handler_arg);
41760         CHECK_ACCESS(route_handler_arg_ptr);
41761         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
41762         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
41763                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41764                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
41765         }
41766         void* onion_message_handler_arg_ptr = untag_ptr(onion_message_handler_arg);
41767         CHECK_ACCESS(onion_message_handler_arg_ptr);
41768         LDKOnionMessageHandler onion_message_handler_arg_conv = *(LDKOnionMessageHandler*)(onion_message_handler_arg_ptr);
41769         if (onion_message_handler_arg_conv.free == LDKOnionMessageHandler_JCalls_free) {
41770                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41771                 LDKOnionMessageHandler_JCalls_cloned(&onion_message_handler_arg_conv);
41772         }
41773         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv, onion_message_handler_arg_conv);
41774         int64_t ret_ref = 0;
41775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41776         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41777         return ret_ref;
41778 }
41779
41780 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
41781         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
41782         *ret_ret = SocketDescriptor_clone(arg);
41783         return tag_ptr(ret_ret, true);
41784 }
41785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41786         void* arg_ptr = untag_ptr(arg);
41787         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
41788         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
41789         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
41790         return ret_conv;
41791 }
41792
41793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41794         void* orig_ptr = untag_ptr(orig);
41795         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
41796         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
41797         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
41798         *ret_ret = SocketDescriptor_clone(orig_conv);
41799         return tag_ptr(ret_ret, true);
41800 }
41801
41802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41803         if (!ptr_is_owned(this_ptr)) return;
41804         void* this_ptr_ptr = untag_ptr(this_ptr);
41805         CHECK_ACCESS(this_ptr_ptr);
41806         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
41807         FREE(untag_ptr(this_ptr));
41808         SocketDescriptor_free(this_ptr_conv);
41809 }
41810
41811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41812         LDKPeerHandleError this_obj_conv;
41813         this_obj_conv.inner = untag_ptr(this_obj);
41814         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41816         PeerHandleError_free(this_obj_conv);
41817 }
41818
41819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz) {
41820         LDKPeerHandleError ret_var = PeerHandleError_new();
41821         int64_t ret_ref = 0;
41822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41823         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41824         return ret_ref;
41825 }
41826
41827 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
41828         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
41829         int64_t ret_ref = 0;
41830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41831         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41832         return ret_ref;
41833 }
41834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41835         LDKPeerHandleError arg_conv;
41836         arg_conv.inner = untag_ptr(arg);
41837         arg_conv.is_owned = ptr_is_owned(arg);
41838         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41839         arg_conv.is_owned = false;
41840         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
41841         return ret_conv;
41842 }
41843
41844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41845         LDKPeerHandleError orig_conv;
41846         orig_conv.inner = untag_ptr(orig);
41847         orig_conv.is_owned = ptr_is_owned(orig);
41848         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41849         orig_conv.is_owned = false;
41850         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
41851         int64_t ret_ref = 0;
41852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41853         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41854         return ret_ref;
41855 }
41856
41857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41858         LDKPeerManager this_obj_conv;
41859         this_obj_conv.inner = untag_ptr(this_obj);
41860         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41862         PeerManager_free(this_obj_conv);
41863 }
41864
41865 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) {
41866         LDKMessageHandler message_handler_conv;
41867         message_handler_conv.inner = untag_ptr(message_handler);
41868         message_handler_conv.is_owned = ptr_is_owned(message_handler);
41869         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
41870         // WARNING: we need a move here but no clone is available for LDKMessageHandler
41871         
41872         uint8_t ephemeral_random_data_arr[32];
41873         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
41874         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
41875         uint8_t (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
41876         void* logger_ptr = untag_ptr(logger);
41877         CHECK_ACCESS(logger_ptr);
41878         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41879         if (logger_conv.free == LDKLogger_JCalls_free) {
41880                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41881                 LDKLogger_JCalls_cloned(&logger_conv);
41882         }
41883         void* custom_message_handler_ptr = untag_ptr(custom_message_handler);
41884         CHECK_ACCESS(custom_message_handler_ptr);
41885         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
41886         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
41887                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41888                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
41889         }
41890         void* node_signer_ptr = untag_ptr(node_signer);
41891         CHECK_ACCESS(node_signer_ptr);
41892         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
41893         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
41894                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41895                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
41896         }
41897         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, current_time, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv, node_signer_conv);
41898         int64_t ret_ref = 0;
41899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41900         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41901         return ret_ref;
41902 }
41903
41904 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
41905         LDKPeerManager this_arg_conv;
41906         this_arg_conv.inner = untag_ptr(this_arg);
41907         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41909         this_arg_conv.is_owned = false;
41910         LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
41911         int64_tArray ret_arr = NULL;
41912         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
41913         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
41914         for (size_t o = 0; o < ret_var.datalen; o++) {
41915                 LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
41916                 *ret_conv_40_conv = ret_var.data[o];
41917                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
41918         }
41919         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
41920         FREE(ret_var.data);
41921         return ret_arr;
41922 }
41923
41924 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) {
41925         LDKPeerManager this_arg_conv;
41926         this_arg_conv.inner = untag_ptr(this_arg);
41927         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41929         this_arg_conv.is_owned = false;
41930         LDKPublicKey their_node_id_ref;
41931         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
41932         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
41933         void* descriptor_ptr = untag_ptr(descriptor);
41934         CHECK_ACCESS(descriptor_ptr);
41935         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
41936         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
41937                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41938                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
41939         }
41940         void* remote_network_address_ptr = untag_ptr(remote_network_address);
41941         CHECK_ACCESS(remote_network_address_ptr);
41942         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
41943         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
41944         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
41945         return tag_ptr(ret_conv, true);
41946 }
41947
41948 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) {
41949         LDKPeerManager this_arg_conv;
41950         this_arg_conv.inner = untag_ptr(this_arg);
41951         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41953         this_arg_conv.is_owned = false;
41954         void* descriptor_ptr = untag_ptr(descriptor);
41955         CHECK_ACCESS(descriptor_ptr);
41956         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
41957         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
41958                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41959                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
41960         }
41961         void* remote_network_address_ptr = untag_ptr(remote_network_address);
41962         CHECK_ACCESS(remote_network_address_ptr);
41963         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
41964         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
41965         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
41966         return tag_ptr(ret_conv, true);
41967 }
41968
41969 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) {
41970         LDKPeerManager this_arg_conv;
41971         this_arg_conv.inner = untag_ptr(this_arg);
41972         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41974         this_arg_conv.is_owned = false;
41975         void* descriptor_ptr = untag_ptr(descriptor);
41976         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
41977         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
41978         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
41979         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
41980         return tag_ptr(ret_conv, true);
41981 }
41982
41983 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) {
41984         LDKPeerManager this_arg_conv;
41985         this_arg_conv.inner = untag_ptr(this_arg);
41986         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41988         this_arg_conv.is_owned = false;
41989         void* peer_descriptor_ptr = untag_ptr(peer_descriptor);
41990         if (ptr_is_owned(peer_descriptor)) { CHECK_ACCESS(peer_descriptor_ptr); }
41991         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
41992         LDKu8slice data_ref;
41993         data_ref.datalen = (*env)->GetArrayLength(env, data);
41994         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
41995         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
41996         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
41997         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
41998         return tag_ptr(ret_conv, true);
41999 }
42000
42001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
42002         LDKPeerManager this_arg_conv;
42003         this_arg_conv.inner = untag_ptr(this_arg);
42004         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42006         this_arg_conv.is_owned = false;
42007         PeerManager_process_events(&this_arg_conv);
42008 }
42009
42010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
42011         LDKPeerManager this_arg_conv;
42012         this_arg_conv.inner = untag_ptr(this_arg);
42013         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42015         this_arg_conv.is_owned = false;
42016         void* descriptor_ptr = untag_ptr(descriptor);
42017         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
42018         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
42019         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
42020 }
42021
42022 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) {
42023         LDKPeerManager this_arg_conv;
42024         this_arg_conv.inner = untag_ptr(this_arg);
42025         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42027         this_arg_conv.is_owned = false;
42028         LDKPublicKey node_id_ref;
42029         CHECK((*env)->GetArrayLength(env, node_id) == 33);
42030         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
42031         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref);
42032 }
42033
42034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
42035         LDKPeerManager this_arg_conv;
42036         this_arg_conv.inner = untag_ptr(this_arg);
42037         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42039         this_arg_conv.is_owned = false;
42040         PeerManager_disconnect_all_peers(&this_arg_conv);
42041 }
42042
42043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
42044         LDKPeerManager this_arg_conv;
42045         this_arg_conv.inner = untag_ptr(this_arg);
42046         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42048         this_arg_conv.is_owned = false;
42049         PeerManager_timer_tick_occurred(&this_arg_conv);
42050 }
42051
42052 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) {
42053         LDKPeerManager this_arg_conv;
42054         this_arg_conv.inner = untag_ptr(this_arg);
42055         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42057         this_arg_conv.is_owned = false;
42058         LDKThreeBytes rgb_ref;
42059         CHECK((*env)->GetArrayLength(env, rgb) == 3);
42060         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
42061         LDKThirtyTwoBytes alias_ref;
42062         CHECK((*env)->GetArrayLength(env, alias) == 32);
42063         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
42064         LDKCVec_NetAddressZ addresses_constr;
42065         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
42066         if (addresses_constr.datalen > 0)
42067                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
42068         else
42069                 addresses_constr.data = NULL;
42070         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
42071         for (size_t m = 0; m < addresses_constr.datalen; m++) {
42072                 int64_t addresses_conv_12 = addresses_vals[m];
42073                 void* addresses_conv_12_ptr = untag_ptr(addresses_conv_12);
42074                 CHECK_ACCESS(addresses_conv_12_ptr);
42075                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
42076                 addresses_constr.data[m] = addresses_conv_12_conv;
42077         }
42078         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
42079         PeerManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
42080 }
42081
42082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
42083         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
42084         return ret_conv;
42085 }
42086
42087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
42088         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
42089         return ret_conv;
42090 }
42091
42092 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42093         LDKHTLCClaim* orig_conv = (LDKHTLCClaim*)untag_ptr(orig);
42094         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_clone(orig_conv));
42095         return ret_conv;
42096 }
42097
42098 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1offered_1timeout(JNIEnv *env, jclass clz) {
42099         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_offered_timeout());
42100         return ret_conv;
42101 }
42102
42103 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1offered_1preimage(JNIEnv *env, jclass clz) {
42104         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_offered_preimage());
42105         return ret_conv;
42106 }
42107
42108 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1accepted_1timeout(JNIEnv *env, jclass clz) {
42109         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_accepted_timeout());
42110         return ret_conv;
42111 }
42112
42113 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1accepted_1preimage(JNIEnv *env, jclass clz) {
42114         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_accepted_preimage());
42115         return ret_conv;
42116 }
42117
42118 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1revocation(JNIEnv *env, jclass clz) {
42119         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_revocation());
42120         return ret_conv;
42121 }
42122
42123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42124         LDKHTLCClaim* a_conv = (LDKHTLCClaim*)untag_ptr(a);
42125         LDKHTLCClaim* b_conv = (LDKHTLCClaim*)untag_ptr(b);
42126         jboolean ret_conv = HTLCClaim_eq(a_conv, b_conv);
42127         return ret_conv;
42128 }
42129
42130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1from_1witness(JNIEnv *env, jclass clz, int8_tArray witness) {
42131         LDKWitness witness_ref;
42132         witness_ref.datalen = (*env)->GetArrayLength(env, witness);
42133         witness_ref.data = MALLOC(witness_ref.datalen, "LDKWitness Bytes");
42134         (*env)->GetByteArrayRegion(env, witness, 0, witness_ref.datalen, witness_ref.data);
42135         witness_ref.data_is_owned = true;
42136         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
42137         *ret_copy = HTLCClaim_from_witness(witness_ref);
42138         int64_t ret_ref = tag_ptr(ret_copy, true);
42139         return ret_ref;
42140 }
42141
42142 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
42143         uint8_t commitment_seed_arr[32];
42144         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
42145         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
42146         uint8_t (*commitment_seed_ref)[32] = &commitment_seed_arr;
42147         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42148         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
42149         return ret_arr;
42150 }
42151
42152 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) {
42153         LDKCVec_u8Z to_holder_script_ref;
42154         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
42155         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
42156         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
42157         LDKCVec_u8Z to_counterparty_script_ref;
42158         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
42159         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
42160         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
42161         LDKOutPoint funding_outpoint_conv;
42162         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
42163         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
42164         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
42165         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
42166         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);
42167         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42168         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42169         Transaction_free(ret_var);
42170         return ret_arr;
42171 }
42172
42173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42174         LDKCounterpartyCommitmentSecrets this_obj_conv;
42175         this_obj_conv.inner = untag_ptr(this_obj);
42176         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42178         CounterpartyCommitmentSecrets_free(this_obj_conv);
42179 }
42180
42181 static inline uint64_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
42182         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
42183         int64_t ret_ref = 0;
42184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42185         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42186         return ret_ref;
42187 }
42188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42189         LDKCounterpartyCommitmentSecrets arg_conv;
42190         arg_conv.inner = untag_ptr(arg);
42191         arg_conv.is_owned = ptr_is_owned(arg);
42192         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42193         arg_conv.is_owned = false;
42194         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
42195         return ret_conv;
42196 }
42197
42198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42199         LDKCounterpartyCommitmentSecrets orig_conv;
42200         orig_conv.inner = untag_ptr(orig);
42201         orig_conv.is_owned = ptr_is_owned(orig);
42202         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42203         orig_conv.is_owned = false;
42204         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
42205         int64_t ret_ref = 0;
42206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42207         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42208         return ret_ref;
42209 }
42210
42211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
42212         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
42213         int64_t ret_ref = 0;
42214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42215         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42216         return ret_ref;
42217 }
42218
42219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
42220         LDKCounterpartyCommitmentSecrets this_arg_conv;
42221         this_arg_conv.inner = untag_ptr(this_arg);
42222         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42224         this_arg_conv.is_owned = false;
42225         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
42226         return ret_conv;
42227 }
42228
42229 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) {
42230         LDKCounterpartyCommitmentSecrets this_arg_conv;
42231         this_arg_conv.inner = untag_ptr(this_arg);
42232         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42234         this_arg_conv.is_owned = false;
42235         LDKThirtyTwoBytes secret_ref;
42236         CHECK((*env)->GetArrayLength(env, secret) == 32);
42237         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
42238         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
42239         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
42240         return tag_ptr(ret_conv, true);
42241 }
42242
42243 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
42244         LDKCounterpartyCommitmentSecrets this_arg_conv;
42245         this_arg_conv.inner = untag_ptr(this_arg);
42246         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42248         this_arg_conv.is_owned = false;
42249         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42250         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
42251         return ret_arr;
42252 }
42253
42254 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
42255         LDKCounterpartyCommitmentSecrets obj_conv;
42256         obj_conv.inner = untag_ptr(obj);
42257         obj_conv.is_owned = ptr_is_owned(obj);
42258         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42259         obj_conv.is_owned = false;
42260         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
42261         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42262         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42263         CVec_u8Z_free(ret_var);
42264         return ret_arr;
42265 }
42266
42267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42268         LDKu8slice ser_ref;
42269         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42270         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42271         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
42272         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
42273         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42274         return tag_ptr(ret_conv, true);
42275 }
42276
42277 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) {
42278         LDKPublicKey per_commitment_point_ref;
42279         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42280         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42281         uint8_t base_secret_arr[32];
42282         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
42283         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
42284         uint8_t (*base_secret_ref)[32] = &base_secret_arr;
42285         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42286         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, derive_private_key(per_commitment_point_ref, base_secret_ref).bytes);
42287         return ret_arr;
42288 }
42289
42290 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) {
42291         LDKPublicKey per_commitment_point_ref;
42292         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42293         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42294         LDKPublicKey base_point_ref;
42295         CHECK((*env)->GetArrayLength(env, base_point) == 33);
42296         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
42297         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42298         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, derive_public_key(per_commitment_point_ref, base_point_ref).compressed_form);
42299         return ret_arr;
42300 }
42301
42302 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) {
42303         uint8_t per_commitment_secret_arr[32];
42304         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
42305         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
42306         uint8_t (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
42307         uint8_t countersignatory_revocation_base_secret_arr[32];
42308         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
42309         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
42310         uint8_t (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
42311         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42312         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref).bytes);
42313         return ret_arr;
42314 }
42315
42316 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) {
42317         LDKPublicKey per_commitment_point_ref;
42318         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42319         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42320         LDKPublicKey countersignatory_revocation_base_point_ref;
42321         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
42322         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
42323         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42324         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref).compressed_form);
42325         return ret_arr;
42326 }
42327
42328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42329         LDKTxCreationKeys this_obj_conv;
42330         this_obj_conv.inner = untag_ptr(this_obj);
42331         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42333         TxCreationKeys_free(this_obj_conv);
42334 }
42335
42336 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
42337         LDKTxCreationKeys this_ptr_conv;
42338         this_ptr_conv.inner = untag_ptr(this_ptr);
42339         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42341         this_ptr_conv.is_owned = false;
42342         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42343         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
42344         return ret_arr;
42345 }
42346
42347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42348         LDKTxCreationKeys this_ptr_conv;
42349         this_ptr_conv.inner = untag_ptr(this_ptr);
42350         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42352         this_ptr_conv.is_owned = false;
42353         LDKPublicKey val_ref;
42354         CHECK((*env)->GetArrayLength(env, val) == 33);
42355         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42356         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
42357 }
42358
42359 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42360         LDKTxCreationKeys this_ptr_conv;
42361         this_ptr_conv.inner = untag_ptr(this_ptr);
42362         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42364         this_ptr_conv.is_owned = false;
42365         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42366         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
42367         return ret_arr;
42368 }
42369
42370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42371         LDKTxCreationKeys this_ptr_conv;
42372         this_ptr_conv.inner = untag_ptr(this_ptr);
42373         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42375         this_ptr_conv.is_owned = false;
42376         LDKPublicKey val_ref;
42377         CHECK((*env)->GetArrayLength(env, val) == 33);
42378         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42379         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
42380 }
42381
42382 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42383         LDKTxCreationKeys this_ptr_conv;
42384         this_ptr_conv.inner = untag_ptr(this_ptr);
42385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42387         this_ptr_conv.is_owned = false;
42388         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42389         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
42390         return ret_arr;
42391 }
42392
42393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42394         LDKTxCreationKeys this_ptr_conv;
42395         this_ptr_conv.inner = untag_ptr(this_ptr);
42396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42398         this_ptr_conv.is_owned = false;
42399         LDKPublicKey val_ref;
42400         CHECK((*env)->GetArrayLength(env, val) == 33);
42401         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42402         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
42403 }
42404
42405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42406         LDKTxCreationKeys this_ptr_conv;
42407         this_ptr_conv.inner = untag_ptr(this_ptr);
42408         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42410         this_ptr_conv.is_owned = false;
42411         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42412         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
42413         return ret_arr;
42414 }
42415
42416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42417         LDKTxCreationKeys this_ptr_conv;
42418         this_ptr_conv.inner = untag_ptr(this_ptr);
42419         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42421         this_ptr_conv.is_owned = false;
42422         LDKPublicKey val_ref;
42423         CHECK((*env)->GetArrayLength(env, val) == 33);
42424         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42425         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
42426 }
42427
42428 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42429         LDKTxCreationKeys this_ptr_conv;
42430         this_ptr_conv.inner = untag_ptr(this_ptr);
42431         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42433         this_ptr_conv.is_owned = false;
42434         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42435         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
42436         return ret_arr;
42437 }
42438
42439 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) {
42440         LDKTxCreationKeys this_ptr_conv;
42441         this_ptr_conv.inner = untag_ptr(this_ptr);
42442         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42444         this_ptr_conv.is_owned = false;
42445         LDKPublicKey val_ref;
42446         CHECK((*env)->GetArrayLength(env, val) == 33);
42447         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42448         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
42449 }
42450
42451 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) {
42452         LDKPublicKey per_commitment_point_arg_ref;
42453         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
42454         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
42455         LDKPublicKey revocation_key_arg_ref;
42456         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
42457         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
42458         LDKPublicKey broadcaster_htlc_key_arg_ref;
42459         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
42460         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
42461         LDKPublicKey countersignatory_htlc_key_arg_ref;
42462         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
42463         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
42464         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
42465         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
42466         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
42467         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);
42468         int64_t ret_ref = 0;
42469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42470         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42471         return ret_ref;
42472 }
42473
42474 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42475         LDKTxCreationKeys a_conv;
42476         a_conv.inner = untag_ptr(a);
42477         a_conv.is_owned = ptr_is_owned(a);
42478         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42479         a_conv.is_owned = false;
42480         LDKTxCreationKeys b_conv;
42481         b_conv.inner = untag_ptr(b);
42482         b_conv.is_owned = ptr_is_owned(b);
42483         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42484         b_conv.is_owned = false;
42485         jboolean ret_conv = TxCreationKeys_eq(&a_conv, &b_conv);
42486         return ret_conv;
42487 }
42488
42489 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
42490         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
42491         int64_t ret_ref = 0;
42492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42493         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42494         return ret_ref;
42495 }
42496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42497         LDKTxCreationKeys arg_conv;
42498         arg_conv.inner = untag_ptr(arg);
42499         arg_conv.is_owned = ptr_is_owned(arg);
42500         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42501         arg_conv.is_owned = false;
42502         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
42503         return ret_conv;
42504 }
42505
42506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42507         LDKTxCreationKeys orig_conv;
42508         orig_conv.inner = untag_ptr(orig);
42509         orig_conv.is_owned = ptr_is_owned(orig);
42510         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42511         orig_conv.is_owned = false;
42512         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
42513         int64_t ret_ref = 0;
42514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42515         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42516         return ret_ref;
42517 }
42518
42519 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
42520         LDKTxCreationKeys obj_conv;
42521         obj_conv.inner = untag_ptr(obj);
42522         obj_conv.is_owned = ptr_is_owned(obj);
42523         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42524         obj_conv.is_owned = false;
42525         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
42526         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42527         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42528         CVec_u8Z_free(ret_var);
42529         return ret_arr;
42530 }
42531
42532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42533         LDKu8slice ser_ref;
42534         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42535         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42536         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
42537         *ret_conv = TxCreationKeys_read(ser_ref);
42538         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42539         return tag_ptr(ret_conv, true);
42540 }
42541
42542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42543         LDKChannelPublicKeys this_obj_conv;
42544         this_obj_conv.inner = untag_ptr(this_obj);
42545         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42547         ChannelPublicKeys_free(this_obj_conv);
42548 }
42549
42550 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
42551         LDKChannelPublicKeys this_ptr_conv;
42552         this_ptr_conv.inner = untag_ptr(this_ptr);
42553         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42555         this_ptr_conv.is_owned = false;
42556         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42557         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
42558         return ret_arr;
42559 }
42560
42561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42562         LDKChannelPublicKeys this_ptr_conv;
42563         this_ptr_conv.inner = untag_ptr(this_ptr);
42564         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42566         this_ptr_conv.is_owned = false;
42567         LDKPublicKey val_ref;
42568         CHECK((*env)->GetArrayLength(env, val) == 33);
42569         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42570         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
42571 }
42572
42573 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42574         LDKChannelPublicKeys this_ptr_conv;
42575         this_ptr_conv.inner = untag_ptr(this_ptr);
42576         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42578         this_ptr_conv.is_owned = false;
42579         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42580         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
42581         return ret_arr;
42582 }
42583
42584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42585         LDKChannelPublicKeys this_ptr_conv;
42586         this_ptr_conv.inner = untag_ptr(this_ptr);
42587         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42589         this_ptr_conv.is_owned = false;
42590         LDKPublicKey val_ref;
42591         CHECK((*env)->GetArrayLength(env, val) == 33);
42592         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42593         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
42594 }
42595
42596 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
42597         LDKChannelPublicKeys this_ptr_conv;
42598         this_ptr_conv.inner = untag_ptr(this_ptr);
42599         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42601         this_ptr_conv.is_owned = false;
42602         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42603         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
42604         return ret_arr;
42605 }
42606
42607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42608         LDKChannelPublicKeys this_ptr_conv;
42609         this_ptr_conv.inner = untag_ptr(this_ptr);
42610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42612         this_ptr_conv.is_owned = false;
42613         LDKPublicKey val_ref;
42614         CHECK((*env)->GetArrayLength(env, val) == 33);
42615         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42616         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
42617 }
42618
42619 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42620         LDKChannelPublicKeys this_ptr_conv;
42621         this_ptr_conv.inner = untag_ptr(this_ptr);
42622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42624         this_ptr_conv.is_owned = false;
42625         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42626         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
42627         return ret_arr;
42628 }
42629
42630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42631         LDKChannelPublicKeys this_ptr_conv;
42632         this_ptr_conv.inner = untag_ptr(this_ptr);
42633         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42635         this_ptr_conv.is_owned = false;
42636         LDKPublicKey val_ref;
42637         CHECK((*env)->GetArrayLength(env, val) == 33);
42638         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42639         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
42640 }
42641
42642 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42643         LDKChannelPublicKeys this_ptr_conv;
42644         this_ptr_conv.inner = untag_ptr(this_ptr);
42645         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42647         this_ptr_conv.is_owned = false;
42648         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42649         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
42650         return ret_arr;
42651 }
42652
42653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42654         LDKChannelPublicKeys this_ptr_conv;
42655         this_ptr_conv.inner = untag_ptr(this_ptr);
42656         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42658         this_ptr_conv.is_owned = false;
42659         LDKPublicKey val_ref;
42660         CHECK((*env)->GetArrayLength(env, val) == 33);
42661         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42662         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
42663 }
42664
42665 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) {
42666         LDKPublicKey funding_pubkey_arg_ref;
42667         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
42668         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
42669         LDKPublicKey revocation_basepoint_arg_ref;
42670         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
42671         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
42672         LDKPublicKey payment_point_arg_ref;
42673         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
42674         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
42675         LDKPublicKey delayed_payment_basepoint_arg_ref;
42676         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
42677         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
42678         LDKPublicKey htlc_basepoint_arg_ref;
42679         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
42680         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
42681         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);
42682         int64_t ret_ref = 0;
42683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42684         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42685         return ret_ref;
42686 }
42687
42688 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
42689         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
42690         int64_t ret_ref = 0;
42691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42692         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42693         return ret_ref;
42694 }
42695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42696         LDKChannelPublicKeys arg_conv;
42697         arg_conv.inner = untag_ptr(arg);
42698         arg_conv.is_owned = ptr_is_owned(arg);
42699         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42700         arg_conv.is_owned = false;
42701         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
42702         return ret_conv;
42703 }
42704
42705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42706         LDKChannelPublicKeys orig_conv;
42707         orig_conv.inner = untag_ptr(orig);
42708         orig_conv.is_owned = ptr_is_owned(orig);
42709         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42710         orig_conv.is_owned = false;
42711         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
42712         int64_t ret_ref = 0;
42713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42714         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42715         return ret_ref;
42716 }
42717
42718 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42719         LDKChannelPublicKeys a_conv;
42720         a_conv.inner = untag_ptr(a);
42721         a_conv.is_owned = ptr_is_owned(a);
42722         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42723         a_conv.is_owned = false;
42724         LDKChannelPublicKeys b_conv;
42725         b_conv.inner = untag_ptr(b);
42726         b_conv.is_owned = ptr_is_owned(b);
42727         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42728         b_conv.is_owned = false;
42729         jboolean ret_conv = ChannelPublicKeys_eq(&a_conv, &b_conv);
42730         return ret_conv;
42731 }
42732
42733 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
42734         LDKChannelPublicKeys obj_conv;
42735         obj_conv.inner = untag_ptr(obj);
42736         obj_conv.is_owned = ptr_is_owned(obj);
42737         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42738         obj_conv.is_owned = false;
42739         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
42740         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42741         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42742         CVec_u8Z_free(ret_var);
42743         return ret_arr;
42744 }
42745
42746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42747         LDKu8slice ser_ref;
42748         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42749         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42750         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
42751         *ret_conv = ChannelPublicKeys_read(ser_ref);
42752         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42753         return tag_ptr(ret_conv, true);
42754 }
42755
42756 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) {
42757         LDKPublicKey per_commitment_point_ref;
42758         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42759         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42760         LDKPublicKey broadcaster_delayed_payment_base_ref;
42761         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
42762         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
42763         LDKPublicKey broadcaster_htlc_base_ref;
42764         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
42765         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
42766         LDKPublicKey countersignatory_revocation_base_ref;
42767         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
42768         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
42769         LDKPublicKey countersignatory_htlc_base_ref;
42770         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
42771         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
42772         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);
42773         int64_t ret_ref = 0;
42774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42775         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42776         return ret_ref;
42777 }
42778
42779 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) {
42780         LDKPublicKey per_commitment_point_ref;
42781         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42782         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42783         LDKChannelPublicKeys broadcaster_keys_conv;
42784         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
42785         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
42786         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
42787         broadcaster_keys_conv.is_owned = false;
42788         LDKChannelPublicKeys countersignatory_keys_conv;
42789         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
42790         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
42791         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
42792         countersignatory_keys_conv.is_owned = false;
42793         LDKTxCreationKeys ret_var = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
42794         int64_t ret_ref = 0;
42795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42796         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42797         return ret_ref;
42798 }
42799
42800 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) {
42801         LDKPublicKey revocation_key_ref;
42802         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
42803         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
42804         LDKPublicKey broadcaster_delayed_payment_key_ref;
42805         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
42806         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
42807         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
42808         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42809         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42810         CVec_u8Z_free(ret_var);
42811         return ret_arr;
42812 }
42813
42814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42815         LDKHTLCOutputInCommitment this_obj_conv;
42816         this_obj_conv.inner = untag_ptr(this_obj);
42817         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42819         HTLCOutputInCommitment_free(this_obj_conv);
42820 }
42821
42822 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
42823         LDKHTLCOutputInCommitment this_ptr_conv;
42824         this_ptr_conv.inner = untag_ptr(this_ptr);
42825         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42827         this_ptr_conv.is_owned = false;
42828         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
42829         return ret_conv;
42830 }
42831
42832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
42833         LDKHTLCOutputInCommitment this_ptr_conv;
42834         this_ptr_conv.inner = untag_ptr(this_ptr);
42835         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42837         this_ptr_conv.is_owned = false;
42838         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
42839 }
42840
42841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42842         LDKHTLCOutputInCommitment this_ptr_conv;
42843         this_ptr_conv.inner = untag_ptr(this_ptr);
42844         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42846         this_ptr_conv.is_owned = false;
42847         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
42848         return ret_conv;
42849 }
42850
42851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42852         LDKHTLCOutputInCommitment this_ptr_conv;
42853         this_ptr_conv.inner = untag_ptr(this_ptr);
42854         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42856         this_ptr_conv.is_owned = false;
42857         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
42858 }
42859
42860 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
42861         LDKHTLCOutputInCommitment this_ptr_conv;
42862         this_ptr_conv.inner = untag_ptr(this_ptr);
42863         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42865         this_ptr_conv.is_owned = false;
42866         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
42867         return ret_conv;
42868 }
42869
42870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42871         LDKHTLCOutputInCommitment this_ptr_conv;
42872         this_ptr_conv.inner = untag_ptr(this_ptr);
42873         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42875         this_ptr_conv.is_owned = false;
42876         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
42877 }
42878
42879 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
42880         LDKHTLCOutputInCommitment this_ptr_conv;
42881         this_ptr_conv.inner = untag_ptr(this_ptr);
42882         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42884         this_ptr_conv.is_owned = false;
42885         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42886         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
42887         return ret_arr;
42888 }
42889
42890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42891         LDKHTLCOutputInCommitment this_ptr_conv;
42892         this_ptr_conv.inner = untag_ptr(this_ptr);
42893         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42895         this_ptr_conv.is_owned = false;
42896         LDKThirtyTwoBytes val_ref;
42897         CHECK((*env)->GetArrayLength(env, val) == 32);
42898         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
42899         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
42900 }
42901
42902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
42903         LDKHTLCOutputInCommitment this_ptr_conv;
42904         this_ptr_conv.inner = untag_ptr(this_ptr);
42905         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42907         this_ptr_conv.is_owned = false;
42908         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
42909         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
42910         int64_t ret_ref = tag_ptr(ret_copy, true);
42911         return ret_ref;
42912 }
42913
42914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(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         void* val_ptr = untag_ptr(val);
42921         CHECK_ACCESS(val_ptr);
42922         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
42923         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
42924         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
42925 }
42926
42927 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) {
42928         LDKThirtyTwoBytes payment_hash_arg_ref;
42929         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
42930         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
42931         void* transaction_output_index_arg_ptr = untag_ptr(transaction_output_index_arg);
42932         CHECK_ACCESS(transaction_output_index_arg_ptr);
42933         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
42934         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(transaction_output_index_arg));
42935         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
42936         int64_t ret_ref = 0;
42937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42938         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42939         return ret_ref;
42940 }
42941
42942 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
42943         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
42944         int64_t ret_ref = 0;
42945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42946         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42947         return ret_ref;
42948 }
42949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42950         LDKHTLCOutputInCommitment arg_conv;
42951         arg_conv.inner = untag_ptr(arg);
42952         arg_conv.is_owned = ptr_is_owned(arg);
42953         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42954         arg_conv.is_owned = false;
42955         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
42956         return ret_conv;
42957 }
42958
42959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42960         LDKHTLCOutputInCommitment orig_conv;
42961         orig_conv.inner = untag_ptr(orig);
42962         orig_conv.is_owned = ptr_is_owned(orig);
42963         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42964         orig_conv.is_owned = false;
42965         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
42966         int64_t ret_ref = 0;
42967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42968         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42969         return ret_ref;
42970 }
42971
42972 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42973         LDKHTLCOutputInCommitment a_conv;
42974         a_conv.inner = untag_ptr(a);
42975         a_conv.is_owned = ptr_is_owned(a);
42976         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42977         a_conv.is_owned = false;
42978         LDKHTLCOutputInCommitment b_conv;
42979         b_conv.inner = untag_ptr(b);
42980         b_conv.is_owned = ptr_is_owned(b);
42981         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42982         b_conv.is_owned = false;
42983         jboolean ret_conv = HTLCOutputInCommitment_eq(&a_conv, &b_conv);
42984         return ret_conv;
42985 }
42986
42987 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
42988         LDKHTLCOutputInCommitment obj_conv;
42989         obj_conv.inner = untag_ptr(obj);
42990         obj_conv.is_owned = ptr_is_owned(obj);
42991         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42992         obj_conv.is_owned = false;
42993         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
42994         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42995         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42996         CVec_u8Z_free(ret_var);
42997         return ret_arr;
42998 }
42999
43000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43001         LDKu8slice ser_ref;
43002         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43003         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43004         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
43005         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
43006         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43007         return tag_ptr(ret_conv, true);
43008 }
43009
43010 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) {
43011         LDKHTLCOutputInCommitment htlc_conv;
43012         htlc_conv.inner = untag_ptr(htlc);
43013         htlc_conv.is_owned = ptr_is_owned(htlc);
43014         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
43015         htlc_conv.is_owned = false;
43016         LDKTxCreationKeys keys_conv;
43017         keys_conv.inner = untag_ptr(keys);
43018         keys_conv.is_owned = ptr_is_owned(keys);
43019         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
43020         keys_conv.is_owned = false;
43021         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
43022         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43023         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43024         CVec_u8Z_free(ret_var);
43025         return ret_arr;
43026 }
43027
43028 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
43029         LDKPublicKey broadcaster_ref;
43030         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
43031         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
43032         LDKPublicKey countersignatory_ref;
43033         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
43034         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
43035         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
43036         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43037         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43038         CVec_u8Z_free(ret_var);
43039         return ret_arr;
43040 }
43041
43042 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) {
43043         uint8_t commitment_txid_arr[32];
43044         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
43045         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
43046         uint8_t (*commitment_txid_ref)[32] = &commitment_txid_arr;
43047         LDKHTLCOutputInCommitment htlc_conv;
43048         htlc_conv.inner = untag_ptr(htlc);
43049         htlc_conv.is_owned = ptr_is_owned(htlc);
43050         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
43051         htlc_conv.is_owned = false;
43052         LDKPublicKey broadcaster_delayed_payment_key_ref;
43053         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
43054         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
43055         LDKPublicKey revocation_key_ref;
43056         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
43057         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
43058         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);
43059         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43060         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43061         Transaction_free(ret_var);
43062         return ret_arr;
43063 }
43064
43065 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) {
43066         LDKSignature local_sig_ref;
43067         CHECK((*env)->GetArrayLength(env, local_sig) == 64);
43068         (*env)->GetByteArrayRegion(env, local_sig, 0, 64, local_sig_ref.compact_form);
43069         LDKSignature remote_sig_ref;
43070         CHECK((*env)->GetArrayLength(env, remote_sig) == 64);
43071         (*env)->GetByteArrayRegion(env, remote_sig, 0, 64, remote_sig_ref.compact_form);
43072         LDKThirtyTwoBytes preimage_ref;
43073         CHECK((*env)->GetArrayLength(env, preimage) == 32);
43074         (*env)->GetByteArrayRegion(env, preimage, 0, 32, preimage_ref.data);
43075         LDKu8slice redeem_script_ref;
43076         redeem_script_ref.datalen = (*env)->GetArrayLength(env, redeem_script);
43077         redeem_script_ref.data = (*env)->GetByteArrayElements (env, redeem_script, NULL);
43078         LDKWitness ret_var = build_htlc_input_witness(local_sig_ref, remote_sig_ref, preimage_ref, redeem_script_ref, opt_anchors);
43079         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43080         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43081         Witness_free(ret_var);
43082         (*env)->ReleaseByteArrayElements(env, redeem_script, (int8_t*)redeem_script_ref.data, 0);
43083         return ret_arr;
43084 }
43085
43086 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1to_1countersignatory_1with_1anchors_1redeemscript(JNIEnv *env, jclass clz, int8_tArray payment_point) {
43087         LDKPublicKey payment_point_ref;
43088         CHECK((*env)->GetArrayLength(env, payment_point) == 33);
43089         (*env)->GetByteArrayRegion(env, payment_point, 0, 33, payment_point_ref.compressed_form);
43090         LDKCVec_u8Z ret_var = get_to_countersignatory_with_anchors_redeemscript(payment_point_ref);
43091         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43092         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43093         CVec_u8Z_free(ret_var);
43094         return ret_arr;
43095 }
43096
43097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
43098         LDKPublicKey funding_pubkey_ref;
43099         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
43100         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
43101         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
43102         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43103         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43104         CVec_u8Z_free(ret_var);
43105         return ret_arr;
43106 }
43107
43108 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) {
43109         LDKPublicKey funding_key_ref;
43110         CHECK((*env)->GetArrayLength(env, funding_key) == 33);
43111         (*env)->GetByteArrayRegion(env, funding_key, 0, 33, funding_key_ref.compressed_form);
43112         LDKSignature funding_sig_ref;
43113         CHECK((*env)->GetArrayLength(env, funding_sig) == 64);
43114         (*env)->GetByteArrayRegion(env, funding_sig, 0, 64, funding_sig_ref.compact_form);
43115         LDKWitness ret_var = build_anchor_input_witness(funding_key_ref, funding_sig_ref);
43116         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43117         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43118         Witness_free(ret_var);
43119         return ret_arr;
43120 }
43121
43122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43123         LDKChannelTransactionParameters this_obj_conv;
43124         this_obj_conv.inner = untag_ptr(this_obj);
43125         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43127         ChannelTransactionParameters_free(this_obj_conv);
43128 }
43129
43130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
43131         LDKChannelTransactionParameters this_ptr_conv;
43132         this_ptr_conv.inner = untag_ptr(this_ptr);
43133         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43135         this_ptr_conv.is_owned = false;
43136         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
43137         int64_t ret_ref = 0;
43138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43139         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43140         return ret_ref;
43141 }
43142
43143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43144         LDKChannelTransactionParameters this_ptr_conv;
43145         this_ptr_conv.inner = untag_ptr(this_ptr);
43146         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43148         this_ptr_conv.is_owned = false;
43149         LDKChannelPublicKeys val_conv;
43150         val_conv.inner = untag_ptr(val);
43151         val_conv.is_owned = ptr_is_owned(val);
43152         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43153         val_conv = ChannelPublicKeys_clone(&val_conv);
43154         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
43155 }
43156
43157 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
43158         LDKChannelTransactionParameters this_ptr_conv;
43159         this_ptr_conv.inner = untag_ptr(this_ptr);
43160         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43162         this_ptr_conv.is_owned = false;
43163         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
43164         return ret_conv;
43165 }
43166
43167 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) {
43168         LDKChannelTransactionParameters this_ptr_conv;
43169         this_ptr_conv.inner = untag_ptr(this_ptr);
43170         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43172         this_ptr_conv.is_owned = false;
43173         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
43174 }
43175
43176 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
43177         LDKChannelTransactionParameters this_ptr_conv;
43178         this_ptr_conv.inner = untag_ptr(this_ptr);
43179         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43181         this_ptr_conv.is_owned = false;
43182         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
43183         return ret_conv;
43184 }
43185
43186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
43187         LDKChannelTransactionParameters this_ptr_conv;
43188         this_ptr_conv.inner = untag_ptr(this_ptr);
43189         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43191         this_ptr_conv.is_owned = false;
43192         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
43193 }
43194
43195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
43196         LDKChannelTransactionParameters this_ptr_conv;
43197         this_ptr_conv.inner = untag_ptr(this_ptr);
43198         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43200         this_ptr_conv.is_owned = false;
43201         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
43202         int64_t ret_ref = 0;
43203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43204         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43205         return ret_ref;
43206 }
43207
43208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43209         LDKChannelTransactionParameters this_ptr_conv;
43210         this_ptr_conv.inner = untag_ptr(this_ptr);
43211         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43213         this_ptr_conv.is_owned = false;
43214         LDKCounterpartyChannelTransactionParameters val_conv;
43215         val_conv.inner = untag_ptr(val);
43216         val_conv.is_owned = ptr_is_owned(val);
43217         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43218         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
43219         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
43220 }
43221
43222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
43223         LDKChannelTransactionParameters this_ptr_conv;
43224         this_ptr_conv.inner = untag_ptr(this_ptr);
43225         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43227         this_ptr_conv.is_owned = false;
43228         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
43229         int64_t ret_ref = 0;
43230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43231         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43232         return ret_ref;
43233 }
43234
43235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43236         LDKChannelTransactionParameters this_ptr_conv;
43237         this_ptr_conv.inner = untag_ptr(this_ptr);
43238         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43240         this_ptr_conv.is_owned = false;
43241         LDKOutPoint val_conv;
43242         val_conv.inner = untag_ptr(val);
43243         val_conv.is_owned = ptr_is_owned(val);
43244         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43245         val_conv = OutPoint_clone(&val_conv);
43246         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
43247 }
43248
43249 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
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         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
43256         return ret_conv;
43257 }
43258
43259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
43260         LDKChannelTransactionParameters this_ptr_conv;
43261         this_ptr_conv.inner = untag_ptr(this_ptr);
43262         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43264         this_ptr_conv.is_owned = false;
43265         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
43266         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
43267 }
43268
43269 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1non_1zero_1fee_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
43270         LDKChannelTransactionParameters this_ptr_conv;
43271         this_ptr_conv.inner = untag_ptr(this_ptr);
43272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43274         this_ptr_conv.is_owned = false;
43275         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_non_zero_fee_anchors(&this_ptr_conv));
43276         return ret_conv;
43277 }
43278
43279 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) {
43280         LDKChannelTransactionParameters this_ptr_conv;
43281         this_ptr_conv.inner = untag_ptr(this_ptr);
43282         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43284         this_ptr_conv.is_owned = false;
43285         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
43286         ChannelTransactionParameters_set_opt_non_zero_fee_anchors(&this_ptr_conv, val_conv);
43287 }
43288
43289 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) {
43290         LDKChannelPublicKeys holder_pubkeys_arg_conv;
43291         holder_pubkeys_arg_conv.inner = untag_ptr(holder_pubkeys_arg);
43292         holder_pubkeys_arg_conv.is_owned = ptr_is_owned(holder_pubkeys_arg);
43293         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
43294         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
43295         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
43296         counterparty_parameters_arg_conv.inner = untag_ptr(counterparty_parameters_arg);
43297         counterparty_parameters_arg_conv.is_owned = ptr_is_owned(counterparty_parameters_arg);
43298         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
43299         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
43300         LDKOutPoint funding_outpoint_arg_conv;
43301         funding_outpoint_arg_conv.inner = untag_ptr(funding_outpoint_arg);
43302         funding_outpoint_arg_conv.is_owned = ptr_is_owned(funding_outpoint_arg);
43303         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
43304         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
43305         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
43306         LDKCOption_NoneZ opt_non_zero_fee_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_non_zero_fee_anchors_arg);
43307         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);
43308         int64_t ret_ref = 0;
43309         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43310         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43311         return ret_ref;
43312 }
43313
43314 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
43315         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
43316         int64_t ret_ref = 0;
43317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43318         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43319         return ret_ref;
43320 }
43321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43322         LDKChannelTransactionParameters arg_conv;
43323         arg_conv.inner = untag_ptr(arg);
43324         arg_conv.is_owned = ptr_is_owned(arg);
43325         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43326         arg_conv.is_owned = false;
43327         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
43328         return ret_conv;
43329 }
43330
43331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43332         LDKChannelTransactionParameters orig_conv;
43333         orig_conv.inner = untag_ptr(orig);
43334         orig_conv.is_owned = ptr_is_owned(orig);
43335         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43336         orig_conv.is_owned = false;
43337         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
43338         int64_t ret_ref = 0;
43339         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43340         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43341         return ret_ref;
43342 }
43343
43344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43345         LDKCounterpartyChannelTransactionParameters this_obj_conv;
43346         this_obj_conv.inner = untag_ptr(this_obj);
43347         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43349         CounterpartyChannelTransactionParameters_free(this_obj_conv);
43350 }
43351
43352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
43353         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43354         this_ptr_conv.inner = untag_ptr(this_ptr);
43355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43357         this_ptr_conv.is_owned = false;
43358         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
43359         int64_t ret_ref = 0;
43360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43361         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43362         return ret_ref;
43363 }
43364
43365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43366         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43367         this_ptr_conv.inner = untag_ptr(this_ptr);
43368         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43370         this_ptr_conv.is_owned = false;
43371         LDKChannelPublicKeys val_conv;
43372         val_conv.inner = untag_ptr(val);
43373         val_conv.is_owned = ptr_is_owned(val);
43374         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43375         val_conv = ChannelPublicKeys_clone(&val_conv);
43376         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
43377 }
43378
43379 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
43380         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43381         this_ptr_conv.inner = untag_ptr(this_ptr);
43382         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43384         this_ptr_conv.is_owned = false;
43385         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
43386         return ret_conv;
43387 }
43388
43389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
43390         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43391         this_ptr_conv.inner = untag_ptr(this_ptr);
43392         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43394         this_ptr_conv.is_owned = false;
43395         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
43396 }
43397
43398 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) {
43399         LDKChannelPublicKeys pubkeys_arg_conv;
43400         pubkeys_arg_conv.inner = untag_ptr(pubkeys_arg);
43401         pubkeys_arg_conv.is_owned = ptr_is_owned(pubkeys_arg);
43402         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
43403         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
43404         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
43405         int64_t ret_ref = 0;
43406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43407         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43408         return ret_ref;
43409 }
43410
43411 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
43412         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
43413         int64_t ret_ref = 0;
43414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43415         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43416         return ret_ref;
43417 }
43418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43419         LDKCounterpartyChannelTransactionParameters arg_conv;
43420         arg_conv.inner = untag_ptr(arg);
43421         arg_conv.is_owned = ptr_is_owned(arg);
43422         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43423         arg_conv.is_owned = false;
43424         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
43425         return ret_conv;
43426 }
43427
43428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43429         LDKCounterpartyChannelTransactionParameters orig_conv;
43430         orig_conv.inner = untag_ptr(orig);
43431         orig_conv.is_owned = ptr_is_owned(orig);
43432         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43433         orig_conv.is_owned = false;
43434         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
43435         int64_t ret_ref = 0;
43436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43437         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43438         return ret_ref;
43439 }
43440
43441 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
43442         LDKChannelTransactionParameters this_arg_conv;
43443         this_arg_conv.inner = untag_ptr(this_arg);
43444         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43446         this_arg_conv.is_owned = false;
43447         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
43448         return ret_conv;
43449 }
43450
43451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
43452         LDKChannelTransactionParameters this_arg_conv;
43453         this_arg_conv.inner = untag_ptr(this_arg);
43454         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43456         this_arg_conv.is_owned = false;
43457         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
43458         int64_t ret_ref = 0;
43459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43460         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43461         return ret_ref;
43462 }
43463
43464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
43465         LDKChannelTransactionParameters this_arg_conv;
43466         this_arg_conv.inner = untag_ptr(this_arg);
43467         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43469         this_arg_conv.is_owned = false;
43470         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
43471         int64_t ret_ref = 0;
43472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43473         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43474         return ret_ref;
43475 }
43476
43477 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
43478         LDKCounterpartyChannelTransactionParameters obj_conv;
43479         obj_conv.inner = untag_ptr(obj);
43480         obj_conv.is_owned = ptr_is_owned(obj);
43481         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43482         obj_conv.is_owned = false;
43483         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
43484         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43485         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43486         CVec_u8Z_free(ret_var);
43487         return ret_arr;
43488 }
43489
43490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43491         LDKu8slice ser_ref;
43492         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43493         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43494         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
43495         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
43496         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43497         return tag_ptr(ret_conv, true);
43498 }
43499
43500 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
43501         LDKChannelTransactionParameters obj_conv;
43502         obj_conv.inner = untag_ptr(obj);
43503         obj_conv.is_owned = ptr_is_owned(obj);
43504         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43505         obj_conv.is_owned = false;
43506         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
43507         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43508         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43509         CVec_u8Z_free(ret_var);
43510         return ret_arr;
43511 }
43512
43513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43514         LDKu8slice ser_ref;
43515         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43516         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43517         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
43518         *ret_conv = ChannelTransactionParameters_read(ser_ref);
43519         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43520         return tag_ptr(ret_conv, true);
43521 }
43522
43523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43524         LDKDirectedChannelTransactionParameters this_obj_conv;
43525         this_obj_conv.inner = untag_ptr(this_obj);
43526         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43528         DirectedChannelTransactionParameters_free(this_obj_conv);
43529 }
43530
43531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
43532         LDKDirectedChannelTransactionParameters this_arg_conv;
43533         this_arg_conv.inner = untag_ptr(this_arg);
43534         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43536         this_arg_conv.is_owned = false;
43537         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
43538         int64_t ret_ref = 0;
43539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43540         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43541         return ret_ref;
43542 }
43543
43544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
43545         LDKDirectedChannelTransactionParameters 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         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&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 int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
43558         LDKDirectedChannelTransactionParameters 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         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
43564         return ret_conv;
43565 }
43566
43567 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
43568         LDKDirectedChannelTransactionParameters this_arg_conv;
43569         this_arg_conv.inner = untag_ptr(this_arg);
43570         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43572         this_arg_conv.is_owned = false;
43573         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
43574         return ret_conv;
43575 }
43576
43577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
43578         LDKDirectedChannelTransactionParameters this_arg_conv;
43579         this_arg_conv.inner = untag_ptr(this_arg);
43580         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43582         this_arg_conv.is_owned = false;
43583         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
43584         int64_t ret_ref = 0;
43585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43586         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43587         return ret_ref;
43588 }
43589
43590 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
43591         LDKDirectedChannelTransactionParameters this_arg_conv;
43592         this_arg_conv.inner = untag_ptr(this_arg);
43593         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43595         this_arg_conv.is_owned = false;
43596         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
43597         return ret_conv;
43598 }
43599
43600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43601         LDKHolderCommitmentTransaction this_obj_conv;
43602         this_obj_conv.inner = untag_ptr(this_obj);
43603         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43605         HolderCommitmentTransaction_free(this_obj_conv);
43606 }
43607
43608 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
43609         LDKHolderCommitmentTransaction this_ptr_conv;
43610         this_ptr_conv.inner = untag_ptr(this_ptr);
43611         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43613         this_ptr_conv.is_owned = false;
43614         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
43615         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
43616         return ret_arr;
43617 }
43618
43619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43620         LDKHolderCommitmentTransaction this_ptr_conv;
43621         this_ptr_conv.inner = untag_ptr(this_ptr);
43622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43624         this_ptr_conv.is_owned = false;
43625         LDKSignature val_ref;
43626         CHECK((*env)->GetArrayLength(env, val) == 64);
43627         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
43628         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
43629 }
43630
43631 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr) {
43632         LDKHolderCommitmentTransaction this_ptr_conv;
43633         this_ptr_conv.inner = untag_ptr(this_ptr);
43634         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43636         this_ptr_conv.is_owned = false;
43637         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
43638         jobjectArray ret_arr = NULL;
43639         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
43640         ;
43641         for (size_t i = 0; i < ret_var.datalen; i++) {
43642                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
43643                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
43644                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
43645         }
43646         
43647         FREE(ret_var.data);
43648         return ret_arr;
43649 }
43650
43651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
43652         LDKHolderCommitmentTransaction this_ptr_conv;
43653         this_ptr_conv.inner = untag_ptr(this_ptr);
43654         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43656         this_ptr_conv.is_owned = false;
43657         LDKCVec_SignatureZ val_constr;
43658         val_constr.datalen = (*env)->GetArrayLength(env, val);
43659         if (val_constr.datalen > 0)
43660                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
43661         else
43662                 val_constr.data = NULL;
43663         for (size_t i = 0; i < val_constr.datalen; i++) {
43664                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
43665                 LDKSignature val_conv_8_ref;
43666                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
43667                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
43668                 val_constr.data[i] = val_conv_8_ref;
43669         }
43670         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
43671 }
43672
43673 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
43674         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
43675         int64_t ret_ref = 0;
43676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43677         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43678         return ret_ref;
43679 }
43680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43681         LDKHolderCommitmentTransaction arg_conv;
43682         arg_conv.inner = untag_ptr(arg);
43683         arg_conv.is_owned = ptr_is_owned(arg);
43684         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43685         arg_conv.is_owned = false;
43686         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
43687         return ret_conv;
43688 }
43689
43690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43691         LDKHolderCommitmentTransaction orig_conv;
43692         orig_conv.inner = untag_ptr(orig);
43693         orig_conv.is_owned = ptr_is_owned(orig);
43694         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43695         orig_conv.is_owned = false;
43696         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
43697         int64_t ret_ref = 0;
43698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43699         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43700         return ret_ref;
43701 }
43702
43703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
43704         LDKHolderCommitmentTransaction obj_conv;
43705         obj_conv.inner = untag_ptr(obj);
43706         obj_conv.is_owned = ptr_is_owned(obj);
43707         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43708         obj_conv.is_owned = false;
43709         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
43710         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43711         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43712         CVec_u8Z_free(ret_var);
43713         return ret_arr;
43714 }
43715
43716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43717         LDKu8slice ser_ref;
43718         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43719         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43720         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
43721         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
43722         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43723         return tag_ptr(ret_conv, true);
43724 }
43725
43726 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) {
43727         LDKCommitmentTransaction commitment_tx_conv;
43728         commitment_tx_conv.inner = untag_ptr(commitment_tx);
43729         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
43730         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
43731         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
43732         LDKSignature counterparty_sig_ref;
43733         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
43734         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
43735         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
43736         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
43737         if (counterparty_htlc_sigs_constr.datalen > 0)
43738                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
43739         else
43740                 counterparty_htlc_sigs_constr.data = NULL;
43741         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
43742                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
43743                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
43744                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
43745                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
43746                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
43747         }
43748         LDKPublicKey holder_funding_key_ref;
43749         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
43750         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
43751         LDKPublicKey counterparty_funding_key_ref;
43752         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
43753         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
43754         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
43755         int64_t ret_ref = 0;
43756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43757         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43758         return ret_ref;
43759 }
43760
43761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43762         LDKBuiltCommitmentTransaction this_obj_conv;
43763         this_obj_conv.inner = untag_ptr(this_obj);
43764         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43766         BuiltCommitmentTransaction_free(this_obj_conv);
43767 }
43768
43769 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
43770         LDKBuiltCommitmentTransaction this_ptr_conv;
43771         this_ptr_conv.inner = untag_ptr(this_ptr);
43772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43774         this_ptr_conv.is_owned = false;
43775         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
43776         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43777         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43778         Transaction_free(ret_var);
43779         return ret_arr;
43780 }
43781
43782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43783         LDKBuiltCommitmentTransaction this_ptr_conv;
43784         this_ptr_conv.inner = untag_ptr(this_ptr);
43785         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43787         this_ptr_conv.is_owned = false;
43788         LDKTransaction val_ref;
43789         val_ref.datalen = (*env)->GetArrayLength(env, val);
43790         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
43791         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
43792         val_ref.data_is_owned = true;
43793         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
43794 }
43795
43796 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
43797         LDKBuiltCommitmentTransaction this_ptr_conv;
43798         this_ptr_conv.inner = untag_ptr(this_ptr);
43799         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43801         this_ptr_conv.is_owned = false;
43802         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43803         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
43804         return ret_arr;
43805 }
43806
43807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43808         LDKBuiltCommitmentTransaction this_ptr_conv;
43809         this_ptr_conv.inner = untag_ptr(this_ptr);
43810         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43812         this_ptr_conv.is_owned = false;
43813         LDKThirtyTwoBytes val_ref;
43814         CHECK((*env)->GetArrayLength(env, val) == 32);
43815         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
43816         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
43817 }
43818
43819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
43820         LDKTransaction transaction_arg_ref;
43821         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
43822         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
43823         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
43824         transaction_arg_ref.data_is_owned = true;
43825         LDKThirtyTwoBytes txid_arg_ref;
43826         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
43827         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
43828         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
43829         int64_t ret_ref = 0;
43830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43831         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43832         return ret_ref;
43833 }
43834
43835 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
43836         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
43837         int64_t ret_ref = 0;
43838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43839         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43840         return ret_ref;
43841 }
43842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43843         LDKBuiltCommitmentTransaction arg_conv;
43844         arg_conv.inner = untag_ptr(arg);
43845         arg_conv.is_owned = ptr_is_owned(arg);
43846         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43847         arg_conv.is_owned = false;
43848         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
43849         return ret_conv;
43850 }
43851
43852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43853         LDKBuiltCommitmentTransaction orig_conv;
43854         orig_conv.inner = untag_ptr(orig);
43855         orig_conv.is_owned = ptr_is_owned(orig);
43856         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43857         orig_conv.is_owned = false;
43858         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
43859         int64_t ret_ref = 0;
43860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43861         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43862         return ret_ref;
43863 }
43864
43865 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
43866         LDKBuiltCommitmentTransaction obj_conv;
43867         obj_conv.inner = untag_ptr(obj);
43868         obj_conv.is_owned = ptr_is_owned(obj);
43869         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43870         obj_conv.is_owned = false;
43871         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
43872         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43873         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43874         CVec_u8Z_free(ret_var);
43875         return ret_arr;
43876 }
43877
43878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43879         LDKu8slice ser_ref;
43880         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43881         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43882         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
43883         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
43884         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43885         return tag_ptr(ret_conv, true);
43886 }
43887
43888 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) {
43889         LDKBuiltCommitmentTransaction this_arg_conv;
43890         this_arg_conv.inner = untag_ptr(this_arg);
43891         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43893         this_arg_conv.is_owned = false;
43894         LDKu8slice funding_redeemscript_ref;
43895         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
43896         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
43897         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43898         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
43899         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
43900         return ret_arr;
43901 }
43902
43903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1sign(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
43904         LDKBuiltCommitmentTransaction this_arg_conv;
43905         this_arg_conv.inner = untag_ptr(this_arg);
43906         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43908         this_arg_conv.is_owned = false;
43909         uint8_t funding_key_arr[32];
43910         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
43911         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
43912         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
43913         LDKu8slice funding_redeemscript_ref;
43914         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
43915         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
43916         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
43917         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
43918         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
43919         return ret_arr;
43920 }
43921
43922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43923         LDKClosingTransaction this_obj_conv;
43924         this_obj_conv.inner = untag_ptr(this_obj);
43925         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43927         ClosingTransaction_free(this_obj_conv);
43928 }
43929
43930 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
43931         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
43932         int64_t ret_ref = 0;
43933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43934         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43935         return ret_ref;
43936 }
43937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43938         LDKClosingTransaction arg_conv;
43939         arg_conv.inner = untag_ptr(arg);
43940         arg_conv.is_owned = ptr_is_owned(arg);
43941         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43942         arg_conv.is_owned = false;
43943         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
43944         return ret_conv;
43945 }
43946
43947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43948         LDKClosingTransaction orig_conv;
43949         orig_conv.inner = untag_ptr(orig);
43950         orig_conv.is_owned = ptr_is_owned(orig);
43951         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43952         orig_conv.is_owned = false;
43953         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
43954         int64_t ret_ref = 0;
43955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43956         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43957         return ret_ref;
43958 }
43959
43960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
43961         LDKClosingTransaction o_conv;
43962         o_conv.inner = untag_ptr(o);
43963         o_conv.is_owned = ptr_is_owned(o);
43964         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43965         o_conv.is_owned = false;
43966         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
43967         return ret_conv;
43968 }
43969
43970 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43971         LDKClosingTransaction a_conv;
43972         a_conv.inner = untag_ptr(a);
43973         a_conv.is_owned = ptr_is_owned(a);
43974         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43975         a_conv.is_owned = false;
43976         LDKClosingTransaction b_conv;
43977         b_conv.inner = untag_ptr(b);
43978         b_conv.is_owned = ptr_is_owned(b);
43979         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43980         b_conv.is_owned = false;
43981         jboolean ret_conv = ClosingTransaction_eq(&a_conv, &b_conv);
43982         return ret_conv;
43983 }
43984
43985 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) {
43986         LDKCVec_u8Z to_holder_script_ref;
43987         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
43988         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
43989         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
43990         LDKCVec_u8Z to_counterparty_script_ref;
43991         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
43992         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
43993         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
43994         LDKOutPoint funding_outpoint_conv;
43995         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
43996         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
43997         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
43998         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
43999         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
44000         int64_t ret_ref = 0;
44001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44002         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44003         return ret_ref;
44004 }
44005
44006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
44007         LDKClosingTransaction this_arg_conv;
44008         this_arg_conv.inner = untag_ptr(this_arg);
44009         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44011         this_arg_conv.is_owned = false;
44012         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
44013         int64_t ret_ref = 0;
44014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44015         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44016         return ret_ref;
44017 }
44018
44019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
44020         LDKClosingTransaction this_arg_conv;
44021         this_arg_conv.inner = untag_ptr(this_arg);
44022         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44024         this_arg_conv.is_owned = false;
44025         LDKOutPoint funding_outpoint_conv;
44026         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
44027         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
44028         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
44029         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
44030         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
44031         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
44032         return tag_ptr(ret_conv, true);
44033 }
44034
44035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44036         LDKClosingTransaction this_arg_conv;
44037         this_arg_conv.inner = untag_ptr(this_arg);
44038         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44040         this_arg_conv.is_owned = false;
44041         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
44042         return ret_conv;
44043 }
44044
44045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44046         LDKClosingTransaction this_arg_conv;
44047         this_arg_conv.inner = untag_ptr(this_arg);
44048         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44050         this_arg_conv.is_owned = false;
44051         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
44052         return ret_conv;
44053 }
44054
44055 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44056         LDKClosingTransaction this_arg_conv;
44057         this_arg_conv.inner = untag_ptr(this_arg);
44058         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44060         this_arg_conv.is_owned = false;
44061         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
44062         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44063         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44064         return ret_arr;
44065 }
44066
44067 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44068         LDKClosingTransaction this_arg_conv;
44069         this_arg_conv.inner = untag_ptr(this_arg);
44070         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44072         this_arg_conv.is_owned = false;
44073         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
44074         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44075         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44076         return ret_arr;
44077 }
44078
44079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44080         LDKTrustedClosingTransaction this_obj_conv;
44081         this_obj_conv.inner = untag_ptr(this_obj);
44082         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44084         TrustedClosingTransaction_free(this_obj_conv);
44085 }
44086
44087 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
44088         LDKTrustedClosingTransaction this_arg_conv;
44089         this_arg_conv.inner = untag_ptr(this_arg);
44090         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44092         this_arg_conv.is_owned = false;
44093         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
44094         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44095         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44096         Transaction_free(ret_var);
44097         return ret_arr;
44098 }
44099
44100 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) {
44101         LDKTrustedClosingTransaction this_arg_conv;
44102         this_arg_conv.inner = untag_ptr(this_arg);
44103         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44105         this_arg_conv.is_owned = false;
44106         LDKu8slice funding_redeemscript_ref;
44107         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44108         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44109         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44110         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
44111         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44112         return ret_arr;
44113 }
44114
44115 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) {
44116         LDKTrustedClosingTransaction this_arg_conv;
44117         this_arg_conv.inner = untag_ptr(this_arg);
44118         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44120         this_arg_conv.is_owned = false;
44121         uint8_t funding_key_arr[32];
44122         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
44123         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
44124         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
44125         LDKu8slice funding_redeemscript_ref;
44126         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44127         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44128         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
44129         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
44130         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44131         return ret_arr;
44132 }
44133
44134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44135         LDKCommitmentTransaction this_obj_conv;
44136         this_obj_conv.inner = untag_ptr(this_obj);
44137         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44139         CommitmentTransaction_free(this_obj_conv);
44140 }
44141
44142 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
44143         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
44144         int64_t ret_ref = 0;
44145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44146         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44147         return ret_ref;
44148 }
44149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44150         LDKCommitmentTransaction arg_conv;
44151         arg_conv.inner = untag_ptr(arg);
44152         arg_conv.is_owned = ptr_is_owned(arg);
44153         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44154         arg_conv.is_owned = false;
44155         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
44156         return ret_conv;
44157 }
44158
44159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44160         LDKCommitmentTransaction orig_conv;
44161         orig_conv.inner = untag_ptr(orig);
44162         orig_conv.is_owned = ptr_is_owned(orig);
44163         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44164         orig_conv.is_owned = false;
44165         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
44166         int64_t ret_ref = 0;
44167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44168         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44169         return ret_ref;
44170 }
44171
44172 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
44173         LDKCommitmentTransaction obj_conv;
44174         obj_conv.inner = untag_ptr(obj);
44175         obj_conv.is_owned = ptr_is_owned(obj);
44176         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44177         obj_conv.is_owned = false;
44178         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
44179         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44180         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44181         CVec_u8Z_free(ret_var);
44182         return ret_arr;
44183 }
44184
44185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44186         LDKu8slice ser_ref;
44187         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44188         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44189         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
44190         *ret_conv = CommitmentTransaction_read(ser_ref);
44191         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44192         return tag_ptr(ret_conv, true);
44193 }
44194
44195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
44196         LDKCommitmentTransaction this_arg_conv;
44197         this_arg_conv.inner = untag_ptr(this_arg);
44198         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44200         this_arg_conv.is_owned = false;
44201         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
44202         return ret_conv;
44203 }
44204
44205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44206         LDKCommitmentTransaction this_arg_conv;
44207         this_arg_conv.inner = untag_ptr(this_arg);
44208         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44210         this_arg_conv.is_owned = false;
44211         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
44212         return ret_conv;
44213 }
44214
44215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44216         LDKCommitmentTransaction 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         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
44222         return ret_conv;
44223 }
44224
44225 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
44226         LDKCommitmentTransaction this_arg_conv;
44227         this_arg_conv.inner = untag_ptr(this_arg);
44228         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44230         this_arg_conv.is_owned = false;
44231         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
44232         return ret_conv;
44233 }
44234
44235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
44236         LDKCommitmentTransaction this_arg_conv;
44237         this_arg_conv.inner = untag_ptr(this_arg);
44238         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44240         this_arg_conv.is_owned = false;
44241         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
44242         int64_t ret_ref = 0;
44243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44244         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44245         return ret_ref;
44246 }
44247
44248 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) {
44249         LDKCommitmentTransaction this_arg_conv;
44250         this_arg_conv.inner = untag_ptr(this_arg);
44251         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44253         this_arg_conv.is_owned = false;
44254         LDKDirectedChannelTransactionParameters channel_parameters_conv;
44255         channel_parameters_conv.inner = untag_ptr(channel_parameters);
44256         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
44257         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
44258         channel_parameters_conv.is_owned = false;
44259         LDKChannelPublicKeys broadcaster_keys_conv;
44260         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
44261         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
44262         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
44263         broadcaster_keys_conv.is_owned = false;
44264         LDKChannelPublicKeys countersignatory_keys_conv;
44265         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
44266         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
44267         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
44268         countersignatory_keys_conv.is_owned = false;
44269         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
44270         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
44271         return tag_ptr(ret_conv, true);
44272 }
44273
44274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44275         LDKTrustedCommitmentTransaction this_obj_conv;
44276         this_obj_conv.inner = untag_ptr(this_obj);
44277         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44279         TrustedCommitmentTransaction_free(this_obj_conv);
44280 }
44281
44282 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
44283         LDKTrustedCommitmentTransaction this_arg_conv;
44284         this_arg_conv.inner = untag_ptr(this_arg);
44285         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44287         this_arg_conv.is_owned = false;
44288         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44289         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
44290         return ret_arr;
44291 }
44292
44293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
44294         LDKTrustedCommitmentTransaction this_arg_conv;
44295         this_arg_conv.inner = untag_ptr(this_arg);
44296         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44298         this_arg_conv.is_owned = false;
44299         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
44300         int64_t ret_ref = 0;
44301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44302         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44303         return ret_ref;
44304 }
44305
44306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
44307         LDKTrustedCommitmentTransaction this_arg_conv;
44308         this_arg_conv.inner = untag_ptr(this_arg);
44309         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44311         this_arg_conv.is_owned = false;
44312         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
44313         int64_t ret_ref = 0;
44314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44315         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44316         return ret_ref;
44317 }
44318
44319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
44320         LDKTrustedCommitmentTransaction this_arg_conv;
44321         this_arg_conv.inner = untag_ptr(this_arg);
44322         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44324         this_arg_conv.is_owned = false;
44325         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
44326         return ret_conv;
44327 }
44328
44329 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) {
44330         LDKTrustedCommitmentTransaction this_arg_conv;
44331         this_arg_conv.inner = untag_ptr(this_arg);
44332         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44334         this_arg_conv.is_owned = false;
44335         uint8_t htlc_base_key_arr[32];
44336         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
44337         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
44338         uint8_t (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
44339         LDKDirectedChannelTransactionParameters channel_parameters_conv;
44340         channel_parameters_conv.inner = untag_ptr(channel_parameters);
44341         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
44342         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
44343         channel_parameters_conv.is_owned = false;
44344         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
44345         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
44346         return tag_ptr(ret_conv, true);
44347 }
44348
44349 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) {
44350         LDKPublicKey broadcaster_payment_basepoint_ref;
44351         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
44352         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
44353         LDKPublicKey countersignatory_payment_basepoint_ref;
44354         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
44355         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
44356         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
44357         return ret_conv;
44358 }
44359
44360 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44361         LDKInitFeatures a_conv;
44362         a_conv.inner = untag_ptr(a);
44363         a_conv.is_owned = ptr_is_owned(a);
44364         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44365         a_conv.is_owned = false;
44366         LDKInitFeatures b_conv;
44367         b_conv.inner = untag_ptr(b);
44368         b_conv.is_owned = ptr_is_owned(b);
44369         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44370         b_conv.is_owned = false;
44371         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
44372         return ret_conv;
44373 }
44374
44375 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44376         LDKNodeFeatures a_conv;
44377         a_conv.inner = untag_ptr(a);
44378         a_conv.is_owned = ptr_is_owned(a);
44379         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44380         a_conv.is_owned = false;
44381         LDKNodeFeatures b_conv;
44382         b_conv.inner = untag_ptr(b);
44383         b_conv.is_owned = ptr_is_owned(b);
44384         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44385         b_conv.is_owned = false;
44386         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
44387         return ret_conv;
44388 }
44389
44390 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44391         LDKChannelFeatures a_conv;
44392         a_conv.inner = untag_ptr(a);
44393         a_conv.is_owned = ptr_is_owned(a);
44394         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44395         a_conv.is_owned = false;
44396         LDKChannelFeatures b_conv;
44397         b_conv.inner = untag_ptr(b);
44398         b_conv.is_owned = ptr_is_owned(b);
44399         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44400         b_conv.is_owned = false;
44401         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
44402         return ret_conv;
44403 }
44404
44405 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44406         LDKInvoiceFeatures a_conv;
44407         a_conv.inner = untag_ptr(a);
44408         a_conv.is_owned = ptr_is_owned(a);
44409         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44410         a_conv.is_owned = false;
44411         LDKInvoiceFeatures b_conv;
44412         b_conv.inner = untag_ptr(b);
44413         b_conv.is_owned = ptr_is_owned(b);
44414         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44415         b_conv.is_owned = false;
44416         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
44417         return ret_conv;
44418 }
44419
44420 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44421         LDKOfferFeatures a_conv;
44422         a_conv.inner = untag_ptr(a);
44423         a_conv.is_owned = ptr_is_owned(a);
44424         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44425         a_conv.is_owned = false;
44426         LDKOfferFeatures b_conv;
44427         b_conv.inner = untag_ptr(b);
44428         b_conv.is_owned = ptr_is_owned(b);
44429         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44430         b_conv.is_owned = false;
44431         jboolean ret_conv = OfferFeatures_eq(&a_conv, &b_conv);
44432         return ret_conv;
44433 }
44434
44435 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44436         LDKInvoiceRequestFeatures a_conv;
44437         a_conv.inner = untag_ptr(a);
44438         a_conv.is_owned = ptr_is_owned(a);
44439         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44440         a_conv.is_owned = false;
44441         LDKInvoiceRequestFeatures b_conv;
44442         b_conv.inner = untag_ptr(b);
44443         b_conv.is_owned = ptr_is_owned(b);
44444         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44445         b_conv.is_owned = false;
44446         jboolean ret_conv = InvoiceRequestFeatures_eq(&a_conv, &b_conv);
44447         return ret_conv;
44448 }
44449
44450 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44451         LDKBolt12InvoiceFeatures a_conv;
44452         a_conv.inner = untag_ptr(a);
44453         a_conv.is_owned = ptr_is_owned(a);
44454         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44455         a_conv.is_owned = false;
44456         LDKBolt12InvoiceFeatures b_conv;
44457         b_conv.inner = untag_ptr(b);
44458         b_conv.is_owned = ptr_is_owned(b);
44459         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44460         b_conv.is_owned = false;
44461         jboolean ret_conv = Bolt12InvoiceFeatures_eq(&a_conv, &b_conv);
44462         return ret_conv;
44463 }
44464
44465 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44466         LDKBlindedHopFeatures a_conv;
44467         a_conv.inner = untag_ptr(a);
44468         a_conv.is_owned = ptr_is_owned(a);
44469         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44470         a_conv.is_owned = false;
44471         LDKBlindedHopFeatures b_conv;
44472         b_conv.inner = untag_ptr(b);
44473         b_conv.is_owned = ptr_is_owned(b);
44474         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44475         b_conv.is_owned = false;
44476         jboolean ret_conv = BlindedHopFeatures_eq(&a_conv, &b_conv);
44477         return ret_conv;
44478 }
44479
44480 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44481         LDKChannelTypeFeatures a_conv;
44482         a_conv.inner = untag_ptr(a);
44483         a_conv.is_owned = ptr_is_owned(a);
44484         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44485         a_conv.is_owned = false;
44486         LDKChannelTypeFeatures b_conv;
44487         b_conv.inner = untag_ptr(b);
44488         b_conv.is_owned = ptr_is_owned(b);
44489         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44490         b_conv.is_owned = false;
44491         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
44492         return ret_conv;
44493 }
44494
44495 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
44496         LDKInitFeatures ret_var = InitFeatures_clone(arg);
44497         int64_t ret_ref = 0;
44498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44499         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44500         return ret_ref;
44501 }
44502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44503         LDKInitFeatures arg_conv;
44504         arg_conv.inner = untag_ptr(arg);
44505         arg_conv.is_owned = ptr_is_owned(arg);
44506         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44507         arg_conv.is_owned = false;
44508         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
44509         return ret_conv;
44510 }
44511
44512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44513         LDKInitFeatures orig_conv;
44514         orig_conv.inner = untag_ptr(orig);
44515         orig_conv.is_owned = ptr_is_owned(orig);
44516         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44517         orig_conv.is_owned = false;
44518         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
44519         int64_t ret_ref = 0;
44520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44521         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44522         return ret_ref;
44523 }
44524
44525 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
44526         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
44527         int64_t ret_ref = 0;
44528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44529         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44530         return ret_ref;
44531 }
44532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44533         LDKNodeFeatures arg_conv;
44534         arg_conv.inner = untag_ptr(arg);
44535         arg_conv.is_owned = ptr_is_owned(arg);
44536         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44537         arg_conv.is_owned = false;
44538         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
44539         return ret_conv;
44540 }
44541
44542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44543         LDKNodeFeatures orig_conv;
44544         orig_conv.inner = untag_ptr(orig);
44545         orig_conv.is_owned = ptr_is_owned(orig);
44546         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44547         orig_conv.is_owned = false;
44548         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
44549         int64_t ret_ref = 0;
44550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44552         return ret_ref;
44553 }
44554
44555 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
44556         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
44557         int64_t ret_ref = 0;
44558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44559         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44560         return ret_ref;
44561 }
44562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44563         LDKChannelFeatures arg_conv;
44564         arg_conv.inner = untag_ptr(arg);
44565         arg_conv.is_owned = ptr_is_owned(arg);
44566         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44567         arg_conv.is_owned = false;
44568         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
44569         return ret_conv;
44570 }
44571
44572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44573         LDKChannelFeatures orig_conv;
44574         orig_conv.inner = untag_ptr(orig);
44575         orig_conv.is_owned = ptr_is_owned(orig);
44576         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44577         orig_conv.is_owned = false;
44578         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
44579         int64_t ret_ref = 0;
44580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44581         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44582         return ret_ref;
44583 }
44584
44585 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
44586         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
44587         int64_t ret_ref = 0;
44588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44589         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44590         return ret_ref;
44591 }
44592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44593         LDKInvoiceFeatures arg_conv;
44594         arg_conv.inner = untag_ptr(arg);
44595         arg_conv.is_owned = ptr_is_owned(arg);
44596         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44597         arg_conv.is_owned = false;
44598         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
44599         return ret_conv;
44600 }
44601
44602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44603         LDKInvoiceFeatures orig_conv;
44604         orig_conv.inner = untag_ptr(orig);
44605         orig_conv.is_owned = ptr_is_owned(orig);
44606         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44607         orig_conv.is_owned = false;
44608         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
44609         int64_t ret_ref = 0;
44610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44611         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44612         return ret_ref;
44613 }
44614
44615 static inline uint64_t OfferFeatures_clone_ptr(LDKOfferFeatures *NONNULL_PTR arg) {
44616         LDKOfferFeatures ret_var = OfferFeatures_clone(arg);
44617         int64_t ret_ref = 0;
44618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44619         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44620         return ret_ref;
44621 }
44622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44623         LDKOfferFeatures arg_conv;
44624         arg_conv.inner = untag_ptr(arg);
44625         arg_conv.is_owned = ptr_is_owned(arg);
44626         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44627         arg_conv.is_owned = false;
44628         int64_t ret_conv = OfferFeatures_clone_ptr(&arg_conv);
44629         return ret_conv;
44630 }
44631
44632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44633         LDKOfferFeatures orig_conv;
44634         orig_conv.inner = untag_ptr(orig);
44635         orig_conv.is_owned = ptr_is_owned(orig);
44636         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44637         orig_conv.is_owned = false;
44638         LDKOfferFeatures ret_var = OfferFeatures_clone(&orig_conv);
44639         int64_t ret_ref = 0;
44640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44641         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44642         return ret_ref;
44643 }
44644
44645 static inline uint64_t InvoiceRequestFeatures_clone_ptr(LDKInvoiceRequestFeatures *NONNULL_PTR arg) {
44646         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(arg);
44647         int64_t ret_ref = 0;
44648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44649         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44650         return ret_ref;
44651 }
44652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44653         LDKInvoiceRequestFeatures arg_conv;
44654         arg_conv.inner = untag_ptr(arg);
44655         arg_conv.is_owned = ptr_is_owned(arg);
44656         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44657         arg_conv.is_owned = false;
44658         int64_t ret_conv = InvoiceRequestFeatures_clone_ptr(&arg_conv);
44659         return ret_conv;
44660 }
44661
44662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44663         LDKInvoiceRequestFeatures orig_conv;
44664         orig_conv.inner = untag_ptr(orig);
44665         orig_conv.is_owned = ptr_is_owned(orig);
44666         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44667         orig_conv.is_owned = false;
44668         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(&orig_conv);
44669         int64_t ret_ref = 0;
44670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44671         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44672         return ret_ref;
44673 }
44674
44675 static inline uint64_t Bolt12InvoiceFeatures_clone_ptr(LDKBolt12InvoiceFeatures *NONNULL_PTR arg) {
44676         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_clone(arg);
44677         int64_t ret_ref = 0;
44678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44679         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44680         return ret_ref;
44681 }
44682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44683         LDKBolt12InvoiceFeatures arg_conv;
44684         arg_conv.inner = untag_ptr(arg);
44685         arg_conv.is_owned = ptr_is_owned(arg);
44686         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44687         arg_conv.is_owned = false;
44688         int64_t ret_conv = Bolt12InvoiceFeatures_clone_ptr(&arg_conv);
44689         return ret_conv;
44690 }
44691
44692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44693         LDKBolt12InvoiceFeatures orig_conv;
44694         orig_conv.inner = untag_ptr(orig);
44695         orig_conv.is_owned = ptr_is_owned(orig);
44696         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44697         orig_conv.is_owned = false;
44698         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_clone(&orig_conv);
44699         int64_t ret_ref = 0;
44700         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44701         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44702         return ret_ref;
44703 }
44704
44705 static inline uint64_t BlindedHopFeatures_clone_ptr(LDKBlindedHopFeatures *NONNULL_PTR arg) {
44706         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_clone(arg);
44707         int64_t ret_ref = 0;
44708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44709         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44710         return ret_ref;
44711 }
44712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44713         LDKBlindedHopFeatures arg_conv;
44714         arg_conv.inner = untag_ptr(arg);
44715         arg_conv.is_owned = ptr_is_owned(arg);
44716         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44717         arg_conv.is_owned = false;
44718         int64_t ret_conv = BlindedHopFeatures_clone_ptr(&arg_conv);
44719         return ret_conv;
44720 }
44721
44722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44723         LDKBlindedHopFeatures orig_conv;
44724         orig_conv.inner = untag_ptr(orig);
44725         orig_conv.is_owned = ptr_is_owned(orig);
44726         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44727         orig_conv.is_owned = false;
44728         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_clone(&orig_conv);
44729         int64_t ret_ref = 0;
44730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44731         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44732         return ret_ref;
44733 }
44734
44735 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
44736         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
44737         int64_t ret_ref = 0;
44738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44739         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44740         return ret_ref;
44741 }
44742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44743         LDKChannelTypeFeatures arg_conv;
44744         arg_conv.inner = untag_ptr(arg);
44745         arg_conv.is_owned = ptr_is_owned(arg);
44746         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44747         arg_conv.is_owned = false;
44748         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
44749         return ret_conv;
44750 }
44751
44752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44753         LDKChannelTypeFeatures orig_conv;
44754         orig_conv.inner = untag_ptr(orig);
44755         orig_conv.is_owned = ptr_is_owned(orig);
44756         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44757         orig_conv.is_owned = false;
44758         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
44759         int64_t ret_ref = 0;
44760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44762         return ret_ref;
44763 }
44764
44765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44766         LDKInitFeatures this_obj_conv;
44767         this_obj_conv.inner = untag_ptr(this_obj);
44768         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44770         InitFeatures_free(this_obj_conv);
44771 }
44772
44773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44774         LDKNodeFeatures this_obj_conv;
44775         this_obj_conv.inner = untag_ptr(this_obj);
44776         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44778         NodeFeatures_free(this_obj_conv);
44779 }
44780
44781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44782         LDKChannelFeatures this_obj_conv;
44783         this_obj_conv.inner = untag_ptr(this_obj);
44784         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44786         ChannelFeatures_free(this_obj_conv);
44787 }
44788
44789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44790         LDKInvoiceFeatures this_obj_conv;
44791         this_obj_conv.inner = untag_ptr(this_obj);
44792         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44794         InvoiceFeatures_free(this_obj_conv);
44795 }
44796
44797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44798         LDKOfferFeatures this_obj_conv;
44799         this_obj_conv.inner = untag_ptr(this_obj);
44800         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44802         OfferFeatures_free(this_obj_conv);
44803 }
44804
44805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44806         LDKInvoiceRequestFeatures this_obj_conv;
44807         this_obj_conv.inner = untag_ptr(this_obj);
44808         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44810         InvoiceRequestFeatures_free(this_obj_conv);
44811 }
44812
44813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44814         LDKBolt12InvoiceFeatures this_obj_conv;
44815         this_obj_conv.inner = untag_ptr(this_obj);
44816         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44818         Bolt12InvoiceFeatures_free(this_obj_conv);
44819 }
44820
44821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44822         LDKBlindedHopFeatures this_obj_conv;
44823         this_obj_conv.inner = untag_ptr(this_obj);
44824         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44826         BlindedHopFeatures_free(this_obj_conv);
44827 }
44828
44829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44830         LDKChannelTypeFeatures this_obj_conv;
44831         this_obj_conv.inner = untag_ptr(this_obj);
44832         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44834         ChannelTypeFeatures_free(this_obj_conv);
44835 }
44836
44837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
44838         LDKInitFeatures ret_var = InitFeatures_empty();
44839         int64_t ret_ref = 0;
44840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44841         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44842         return ret_ref;
44843 }
44844
44845 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44846         LDKInitFeatures this_arg_conv;
44847         this_arg_conv.inner = untag_ptr(this_arg);
44848         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44850         this_arg_conv.is_owned = false;
44851         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
44852         return ret_conv;
44853 }
44854
44855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
44856         LDKNodeFeatures ret_var = NodeFeatures_empty();
44857         int64_t ret_ref = 0;
44858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44859         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44860         return ret_ref;
44861 }
44862
44863 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44864         LDKNodeFeatures this_arg_conv;
44865         this_arg_conv.inner = untag_ptr(this_arg);
44866         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44868         this_arg_conv.is_owned = false;
44869         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
44870         return ret_conv;
44871 }
44872
44873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
44874         LDKChannelFeatures ret_var = ChannelFeatures_empty();
44875         int64_t ret_ref = 0;
44876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44877         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44878         return ret_ref;
44879 }
44880
44881 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44882         LDKChannelFeatures this_arg_conv;
44883         this_arg_conv.inner = untag_ptr(this_arg);
44884         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44886         this_arg_conv.is_owned = false;
44887         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
44888         return ret_conv;
44889 }
44890
44891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
44892         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
44893         int64_t ret_ref = 0;
44894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44895         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44896         return ret_ref;
44897 }
44898
44899 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44900         LDKInvoiceFeatures this_arg_conv;
44901         this_arg_conv.inner = untag_ptr(this_arg);
44902         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44904         this_arg_conv.is_owned = false;
44905         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
44906         return ret_conv;
44907 }
44908
44909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1empty(JNIEnv *env, jclass clz) {
44910         LDKOfferFeatures ret_var = OfferFeatures_empty();
44911         int64_t ret_ref = 0;
44912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44913         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44914         return ret_ref;
44915 }
44916
44917 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44918         LDKOfferFeatures this_arg_conv;
44919         this_arg_conv.inner = untag_ptr(this_arg);
44920         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44922         this_arg_conv.is_owned = false;
44923         jboolean ret_conv = OfferFeatures_requires_unknown_bits(&this_arg_conv);
44924         return ret_conv;
44925 }
44926
44927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1empty(JNIEnv *env, jclass clz) {
44928         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_empty();
44929         int64_t ret_ref = 0;
44930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44931         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44932         return ret_ref;
44933 }
44934
44935 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44936         LDKInvoiceRequestFeatures this_arg_conv;
44937         this_arg_conv.inner = untag_ptr(this_arg);
44938         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44940         this_arg_conv.is_owned = false;
44941         jboolean ret_conv = InvoiceRequestFeatures_requires_unknown_bits(&this_arg_conv);
44942         return ret_conv;
44943 }
44944
44945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
44946         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_empty();
44947         int64_t ret_ref = 0;
44948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44949         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44950         return ret_ref;
44951 }
44952
44953 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44954         LDKBolt12InvoiceFeatures this_arg_conv;
44955         this_arg_conv.inner = untag_ptr(this_arg);
44956         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44958         this_arg_conv.is_owned = false;
44959         jboolean ret_conv = Bolt12InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
44960         return ret_conv;
44961 }
44962
44963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1empty(JNIEnv *env, jclass clz) {
44964         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_empty();
44965         int64_t ret_ref = 0;
44966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44967         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44968         return ret_ref;
44969 }
44970
44971 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44972         LDKBlindedHopFeatures this_arg_conv;
44973         this_arg_conv.inner = untag_ptr(this_arg);
44974         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44976         this_arg_conv.is_owned = false;
44977         jboolean ret_conv = BlindedHopFeatures_requires_unknown_bits(&this_arg_conv);
44978         return ret_conv;
44979 }
44980
44981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
44982         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
44983         int64_t ret_ref = 0;
44984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44985         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44986         return ret_ref;
44987 }
44988
44989 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44990         LDKChannelTypeFeatures this_arg_conv;
44991         this_arg_conv.inner = untag_ptr(this_arg);
44992         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44994         this_arg_conv.is_owned = false;
44995         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
44996         return ret_conv;
44997 }
44998
44999 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45000         LDKInitFeatures obj_conv;
45001         obj_conv.inner = untag_ptr(obj);
45002         obj_conv.is_owned = ptr_is_owned(obj);
45003         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45004         obj_conv.is_owned = false;
45005         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
45006         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45007         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45008         CVec_u8Z_free(ret_var);
45009         return ret_arr;
45010 }
45011
45012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45013         LDKu8slice ser_ref;
45014         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45015         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45016         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
45017         *ret_conv = InitFeatures_read(ser_ref);
45018         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45019         return tag_ptr(ret_conv, true);
45020 }
45021
45022 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45023         LDKChannelFeatures obj_conv;
45024         obj_conv.inner = untag_ptr(obj);
45025         obj_conv.is_owned = ptr_is_owned(obj);
45026         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45027         obj_conv.is_owned = false;
45028         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
45029         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45030         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45031         CVec_u8Z_free(ret_var);
45032         return ret_arr;
45033 }
45034
45035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45036         LDKu8slice ser_ref;
45037         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45038         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45039         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
45040         *ret_conv = ChannelFeatures_read(ser_ref);
45041         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45042         return tag_ptr(ret_conv, true);
45043 }
45044
45045 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45046         LDKNodeFeatures obj_conv;
45047         obj_conv.inner = untag_ptr(obj);
45048         obj_conv.is_owned = ptr_is_owned(obj);
45049         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45050         obj_conv.is_owned = false;
45051         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
45052         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45053         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45054         CVec_u8Z_free(ret_var);
45055         return ret_arr;
45056 }
45057
45058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45059         LDKu8slice ser_ref;
45060         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45061         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45062         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
45063         *ret_conv = NodeFeatures_read(ser_ref);
45064         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45065         return tag_ptr(ret_conv, true);
45066 }
45067
45068 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45069         LDKInvoiceFeatures obj_conv;
45070         obj_conv.inner = untag_ptr(obj);
45071         obj_conv.is_owned = ptr_is_owned(obj);
45072         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45073         obj_conv.is_owned = false;
45074         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
45075         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45076         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45077         CVec_u8Z_free(ret_var);
45078         return ret_arr;
45079 }
45080
45081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45082         LDKu8slice ser_ref;
45083         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45084         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45085         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
45086         *ret_conv = InvoiceFeatures_read(ser_ref);
45087         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45088         return tag_ptr(ret_conv, true);
45089 }
45090
45091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45092         LDKBlindedHopFeatures obj_conv;
45093         obj_conv.inner = untag_ptr(obj);
45094         obj_conv.is_owned = ptr_is_owned(obj);
45095         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45096         obj_conv.is_owned = false;
45097         LDKCVec_u8Z ret_var = BlindedHopFeatures_write(&obj_conv);
45098         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45099         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45100         CVec_u8Z_free(ret_var);
45101         return ret_arr;
45102 }
45103
45104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45105         LDKu8slice ser_ref;
45106         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45107         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45108         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
45109         *ret_conv = BlindedHopFeatures_read(ser_ref);
45110         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45111         return tag_ptr(ret_conv, true);
45112 }
45113
45114 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45115         LDKChannelTypeFeatures obj_conv;
45116         obj_conv.inner = untag_ptr(obj);
45117         obj_conv.is_owned = ptr_is_owned(obj);
45118         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45119         obj_conv.is_owned = false;
45120         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
45121         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45122         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45123         CVec_u8Z_free(ret_var);
45124         return ret_arr;
45125 }
45126
45127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45128         LDKu8slice ser_ref;
45129         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45130         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45131         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
45132         *ret_conv = ChannelTypeFeatures_read(ser_ref);
45133         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45134         return tag_ptr(ret_conv, true);
45135 }
45136
45137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45138         LDKInitFeatures this_arg_conv;
45139         this_arg_conv.inner = untag_ptr(this_arg);
45140         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45142         this_arg_conv.is_owned = false;
45143         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
45144 }
45145
45146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45147         LDKInitFeatures this_arg_conv;
45148         this_arg_conv.inner = untag_ptr(this_arg);
45149         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45151         this_arg_conv.is_owned = false;
45152         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
45153 }
45154
45155 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45156         LDKInitFeatures this_arg_conv;
45157         this_arg_conv.inner = untag_ptr(this_arg);
45158         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45160         this_arg_conv.is_owned = false;
45161         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
45162         return ret_conv;
45163 }
45164
45165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45166         LDKNodeFeatures this_arg_conv;
45167         this_arg_conv.inner = untag_ptr(this_arg);
45168         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45170         this_arg_conv.is_owned = false;
45171         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
45172 }
45173
45174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45175         LDKNodeFeatures this_arg_conv;
45176         this_arg_conv.inner = untag_ptr(this_arg);
45177         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45179         this_arg_conv.is_owned = false;
45180         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
45181 }
45182
45183 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45184         LDKNodeFeatures this_arg_conv;
45185         this_arg_conv.inner = untag_ptr(this_arg);
45186         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45188         this_arg_conv.is_owned = false;
45189         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
45190         return ret_conv;
45191 }
45192
45193 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45194         LDKInitFeatures this_arg_conv;
45195         this_arg_conv.inner = untag_ptr(this_arg);
45196         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45198         this_arg_conv.is_owned = false;
45199         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
45200         return ret_conv;
45201 }
45202
45203 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45204         LDKNodeFeatures this_arg_conv;
45205         this_arg_conv.inner = untag_ptr(this_arg);
45206         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45208         this_arg_conv.is_owned = false;
45209         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
45210         return ret_conv;
45211 }
45212
45213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45214         LDKInitFeatures this_arg_conv;
45215         this_arg_conv.inner = untag_ptr(this_arg);
45216         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45218         this_arg_conv.is_owned = false;
45219         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
45220 }
45221
45222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45223         LDKInitFeatures this_arg_conv;
45224         this_arg_conv.inner = untag_ptr(this_arg);
45225         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45227         this_arg_conv.is_owned = false;
45228         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
45229 }
45230
45231 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
45232         LDKInitFeatures this_arg_conv;
45233         this_arg_conv.inner = untag_ptr(this_arg);
45234         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45236         this_arg_conv.is_owned = false;
45237         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
45238         return ret_conv;
45239 }
45240
45241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45242         LDKInitFeatures this_arg_conv;
45243         this_arg_conv.inner = untag_ptr(this_arg);
45244         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45246         this_arg_conv.is_owned = false;
45247         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
45248 }
45249
45250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45251         LDKInitFeatures this_arg_conv;
45252         this_arg_conv.inner = untag_ptr(this_arg);
45253         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45255         this_arg_conv.is_owned = false;
45256         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
45257 }
45258
45259 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45260         LDKInitFeatures this_arg_conv;
45261         this_arg_conv.inner = untag_ptr(this_arg);
45262         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45264         this_arg_conv.is_owned = false;
45265         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
45266         return ret_conv;
45267 }
45268
45269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45270         LDKNodeFeatures this_arg_conv;
45271         this_arg_conv.inner = untag_ptr(this_arg);
45272         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45274         this_arg_conv.is_owned = false;
45275         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
45276 }
45277
45278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45279         LDKNodeFeatures this_arg_conv;
45280         this_arg_conv.inner = untag_ptr(this_arg);
45281         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45283         this_arg_conv.is_owned = false;
45284         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
45285 }
45286
45287 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45288         LDKNodeFeatures this_arg_conv;
45289         this_arg_conv.inner = untag_ptr(this_arg);
45290         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45292         this_arg_conv.is_owned = false;
45293         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
45294         return ret_conv;
45295 }
45296
45297 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45298         LDKInitFeatures this_arg_conv;
45299         this_arg_conv.inner = untag_ptr(this_arg);
45300         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45302         this_arg_conv.is_owned = false;
45303         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
45304         return ret_conv;
45305 }
45306
45307 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45308         LDKNodeFeatures this_arg_conv;
45309         this_arg_conv.inner = untag_ptr(this_arg);
45310         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45312         this_arg_conv.is_owned = false;
45313         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
45314         return ret_conv;
45315 }
45316
45317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45318         LDKInitFeatures this_arg_conv;
45319         this_arg_conv.inner = untag_ptr(this_arg);
45320         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45322         this_arg_conv.is_owned = false;
45323         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
45324 }
45325
45326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45327         LDKInitFeatures this_arg_conv;
45328         this_arg_conv.inner = untag_ptr(this_arg);
45329         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45331         this_arg_conv.is_owned = false;
45332         InitFeatures_set_gossip_queries_required(&this_arg_conv);
45333 }
45334
45335 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45336         LDKInitFeatures this_arg_conv;
45337         this_arg_conv.inner = untag_ptr(this_arg);
45338         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45340         this_arg_conv.is_owned = false;
45341         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
45342         return ret_conv;
45343 }
45344
45345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45346         LDKNodeFeatures this_arg_conv;
45347         this_arg_conv.inner = untag_ptr(this_arg);
45348         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45350         this_arg_conv.is_owned = false;
45351         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
45352 }
45353
45354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45355         LDKNodeFeatures this_arg_conv;
45356         this_arg_conv.inner = untag_ptr(this_arg);
45357         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45359         this_arg_conv.is_owned = false;
45360         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
45361 }
45362
45363 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45364         LDKNodeFeatures this_arg_conv;
45365         this_arg_conv.inner = untag_ptr(this_arg);
45366         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45368         this_arg_conv.is_owned = false;
45369         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
45370         return ret_conv;
45371 }
45372
45373 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45374         LDKInitFeatures this_arg_conv;
45375         this_arg_conv.inner = untag_ptr(this_arg);
45376         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45378         this_arg_conv.is_owned = false;
45379         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
45380         return ret_conv;
45381 }
45382
45383 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45384         LDKNodeFeatures this_arg_conv;
45385         this_arg_conv.inner = untag_ptr(this_arg);
45386         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45388         this_arg_conv.is_owned = false;
45389         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
45390         return ret_conv;
45391 }
45392
45393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45394         LDKInitFeatures this_arg_conv;
45395         this_arg_conv.inner = untag_ptr(this_arg);
45396         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45398         this_arg_conv.is_owned = false;
45399         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
45400 }
45401
45402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45403         LDKInitFeatures this_arg_conv;
45404         this_arg_conv.inner = untag_ptr(this_arg);
45405         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45407         this_arg_conv.is_owned = false;
45408         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
45409 }
45410
45411 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45412         LDKInitFeatures this_arg_conv;
45413         this_arg_conv.inner = untag_ptr(this_arg);
45414         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45416         this_arg_conv.is_owned = false;
45417         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
45418         return ret_conv;
45419 }
45420
45421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45422         LDKNodeFeatures this_arg_conv;
45423         this_arg_conv.inner = untag_ptr(this_arg);
45424         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45426         this_arg_conv.is_owned = false;
45427         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
45428 }
45429
45430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45431         LDKNodeFeatures this_arg_conv;
45432         this_arg_conv.inner = untag_ptr(this_arg);
45433         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45435         this_arg_conv.is_owned = false;
45436         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
45437 }
45438
45439 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45440         LDKNodeFeatures this_arg_conv;
45441         this_arg_conv.inner = untag_ptr(this_arg);
45442         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45444         this_arg_conv.is_owned = false;
45445         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
45446         return ret_conv;
45447 }
45448
45449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45450         LDKInvoiceFeatures this_arg_conv;
45451         this_arg_conv.inner = untag_ptr(this_arg);
45452         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45454         this_arg_conv.is_owned = false;
45455         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
45456 }
45457
45458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45459         LDKInvoiceFeatures this_arg_conv;
45460         this_arg_conv.inner = untag_ptr(this_arg);
45461         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45463         this_arg_conv.is_owned = false;
45464         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
45465 }
45466
45467 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45468         LDKInvoiceFeatures this_arg_conv;
45469         this_arg_conv.inner = untag_ptr(this_arg);
45470         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45472         this_arg_conv.is_owned = false;
45473         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
45474         return ret_conv;
45475 }
45476
45477 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45478         LDKInitFeatures this_arg_conv;
45479         this_arg_conv.inner = untag_ptr(this_arg);
45480         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45482         this_arg_conv.is_owned = false;
45483         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
45484         return ret_conv;
45485 }
45486
45487 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45488         LDKNodeFeatures this_arg_conv;
45489         this_arg_conv.inner = untag_ptr(this_arg);
45490         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45492         this_arg_conv.is_owned = false;
45493         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
45494         return ret_conv;
45495 }
45496
45497 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45498         LDKInvoiceFeatures this_arg_conv;
45499         this_arg_conv.inner = untag_ptr(this_arg);
45500         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45502         this_arg_conv.is_owned = false;
45503         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
45504         return ret_conv;
45505 }
45506
45507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45508         LDKInitFeatures this_arg_conv;
45509         this_arg_conv.inner = untag_ptr(this_arg);
45510         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45512         this_arg_conv.is_owned = false;
45513         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
45514 }
45515
45516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45517         LDKInitFeatures this_arg_conv;
45518         this_arg_conv.inner = untag_ptr(this_arg);
45519         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45521         this_arg_conv.is_owned = false;
45522         InitFeatures_set_static_remote_key_required(&this_arg_conv);
45523 }
45524
45525 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45526         LDKInitFeatures this_arg_conv;
45527         this_arg_conv.inner = untag_ptr(this_arg);
45528         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45530         this_arg_conv.is_owned = false;
45531         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
45532         return ret_conv;
45533 }
45534
45535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45536         LDKNodeFeatures this_arg_conv;
45537         this_arg_conv.inner = untag_ptr(this_arg);
45538         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45540         this_arg_conv.is_owned = false;
45541         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
45542 }
45543
45544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45545         LDKNodeFeatures this_arg_conv;
45546         this_arg_conv.inner = untag_ptr(this_arg);
45547         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45549         this_arg_conv.is_owned = false;
45550         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
45551 }
45552
45553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45554         LDKNodeFeatures this_arg_conv;
45555         this_arg_conv.inner = untag_ptr(this_arg);
45556         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45558         this_arg_conv.is_owned = false;
45559         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
45560         return ret_conv;
45561 }
45562
45563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45564         LDKChannelTypeFeatures this_arg_conv;
45565         this_arg_conv.inner = untag_ptr(this_arg);
45566         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45568         this_arg_conv.is_owned = false;
45569         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
45570 }
45571
45572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45573         LDKChannelTypeFeatures this_arg_conv;
45574         this_arg_conv.inner = untag_ptr(this_arg);
45575         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45577         this_arg_conv.is_owned = false;
45578         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
45579 }
45580
45581 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45582         LDKChannelTypeFeatures this_arg_conv;
45583         this_arg_conv.inner = untag_ptr(this_arg);
45584         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45586         this_arg_conv.is_owned = false;
45587         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
45588         return ret_conv;
45589 }
45590
45591 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45592         LDKInitFeatures this_arg_conv;
45593         this_arg_conv.inner = untag_ptr(this_arg);
45594         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45596         this_arg_conv.is_owned = false;
45597         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
45598         return ret_conv;
45599 }
45600
45601 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45602         LDKNodeFeatures this_arg_conv;
45603         this_arg_conv.inner = untag_ptr(this_arg);
45604         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45606         this_arg_conv.is_owned = false;
45607         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
45608         return ret_conv;
45609 }
45610
45611 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45612         LDKChannelTypeFeatures this_arg_conv;
45613         this_arg_conv.inner = untag_ptr(this_arg);
45614         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45616         this_arg_conv.is_owned = false;
45617         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
45618         return ret_conv;
45619 }
45620
45621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45622         LDKInitFeatures this_arg_conv;
45623         this_arg_conv.inner = untag_ptr(this_arg);
45624         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45626         this_arg_conv.is_owned = false;
45627         InitFeatures_set_payment_secret_optional(&this_arg_conv);
45628 }
45629
45630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45631         LDKInitFeatures this_arg_conv;
45632         this_arg_conv.inner = untag_ptr(this_arg);
45633         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45635         this_arg_conv.is_owned = false;
45636         InitFeatures_set_payment_secret_required(&this_arg_conv);
45637 }
45638
45639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45640         LDKInitFeatures this_arg_conv;
45641         this_arg_conv.inner = untag_ptr(this_arg);
45642         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45644         this_arg_conv.is_owned = false;
45645         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
45646         return ret_conv;
45647 }
45648
45649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45650         LDKNodeFeatures this_arg_conv;
45651         this_arg_conv.inner = untag_ptr(this_arg);
45652         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45654         this_arg_conv.is_owned = false;
45655         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
45656 }
45657
45658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45659         LDKNodeFeatures this_arg_conv;
45660         this_arg_conv.inner = untag_ptr(this_arg);
45661         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45663         this_arg_conv.is_owned = false;
45664         NodeFeatures_set_payment_secret_required(&this_arg_conv);
45665 }
45666
45667 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45668         LDKNodeFeatures this_arg_conv;
45669         this_arg_conv.inner = untag_ptr(this_arg);
45670         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45672         this_arg_conv.is_owned = false;
45673         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
45674         return ret_conv;
45675 }
45676
45677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45678         LDKInvoiceFeatures this_arg_conv;
45679         this_arg_conv.inner = untag_ptr(this_arg);
45680         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45682         this_arg_conv.is_owned = false;
45683         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
45684 }
45685
45686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45687         LDKInvoiceFeatures this_arg_conv;
45688         this_arg_conv.inner = untag_ptr(this_arg);
45689         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45691         this_arg_conv.is_owned = false;
45692         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
45693 }
45694
45695 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45696         LDKInvoiceFeatures this_arg_conv;
45697         this_arg_conv.inner = untag_ptr(this_arg);
45698         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45700         this_arg_conv.is_owned = false;
45701         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
45702         return ret_conv;
45703 }
45704
45705 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45706         LDKInitFeatures this_arg_conv;
45707         this_arg_conv.inner = untag_ptr(this_arg);
45708         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45710         this_arg_conv.is_owned = false;
45711         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
45712         return ret_conv;
45713 }
45714
45715 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45716         LDKNodeFeatures this_arg_conv;
45717         this_arg_conv.inner = untag_ptr(this_arg);
45718         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45720         this_arg_conv.is_owned = false;
45721         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
45722         return ret_conv;
45723 }
45724
45725 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45726         LDKInvoiceFeatures this_arg_conv;
45727         this_arg_conv.inner = untag_ptr(this_arg);
45728         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45730         this_arg_conv.is_owned = false;
45731         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
45732         return ret_conv;
45733 }
45734
45735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45736         LDKInitFeatures this_arg_conv;
45737         this_arg_conv.inner = untag_ptr(this_arg);
45738         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45740         this_arg_conv.is_owned = false;
45741         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
45742 }
45743
45744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45745         LDKInitFeatures this_arg_conv;
45746         this_arg_conv.inner = untag_ptr(this_arg);
45747         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45749         this_arg_conv.is_owned = false;
45750         InitFeatures_set_basic_mpp_required(&this_arg_conv);
45751 }
45752
45753 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45754         LDKInitFeatures this_arg_conv;
45755         this_arg_conv.inner = untag_ptr(this_arg);
45756         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45758         this_arg_conv.is_owned = false;
45759         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
45760         return ret_conv;
45761 }
45762
45763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45764         LDKNodeFeatures this_arg_conv;
45765         this_arg_conv.inner = untag_ptr(this_arg);
45766         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45768         this_arg_conv.is_owned = false;
45769         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
45770 }
45771
45772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45773         LDKNodeFeatures this_arg_conv;
45774         this_arg_conv.inner = untag_ptr(this_arg);
45775         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45777         this_arg_conv.is_owned = false;
45778         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
45779 }
45780
45781 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45782         LDKNodeFeatures this_arg_conv;
45783         this_arg_conv.inner = untag_ptr(this_arg);
45784         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45786         this_arg_conv.is_owned = false;
45787         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
45788         return ret_conv;
45789 }
45790
45791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45792         LDKInvoiceFeatures this_arg_conv;
45793         this_arg_conv.inner = untag_ptr(this_arg);
45794         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45796         this_arg_conv.is_owned = false;
45797         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
45798 }
45799
45800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45801         LDKInvoiceFeatures this_arg_conv;
45802         this_arg_conv.inner = untag_ptr(this_arg);
45803         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45805         this_arg_conv.is_owned = false;
45806         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
45807 }
45808
45809 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45810         LDKInvoiceFeatures this_arg_conv;
45811         this_arg_conv.inner = untag_ptr(this_arg);
45812         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45814         this_arg_conv.is_owned = false;
45815         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
45816         return ret_conv;
45817 }
45818
45819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45820         LDKBolt12InvoiceFeatures this_arg_conv;
45821         this_arg_conv.inner = untag_ptr(this_arg);
45822         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45824         this_arg_conv.is_owned = false;
45825         Bolt12InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
45826 }
45827
45828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45829         LDKBolt12InvoiceFeatures this_arg_conv;
45830         this_arg_conv.inner = untag_ptr(this_arg);
45831         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45833         this_arg_conv.is_owned = false;
45834         Bolt12InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
45835 }
45836
45837 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45838         LDKBolt12InvoiceFeatures this_arg_conv;
45839         this_arg_conv.inner = untag_ptr(this_arg);
45840         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45842         this_arg_conv.is_owned = false;
45843         jboolean ret_conv = Bolt12InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
45844         return ret_conv;
45845 }
45846
45847 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45848         LDKInitFeatures this_arg_conv;
45849         this_arg_conv.inner = untag_ptr(this_arg);
45850         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45852         this_arg_conv.is_owned = false;
45853         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
45854         return ret_conv;
45855 }
45856
45857 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45858         LDKNodeFeatures this_arg_conv;
45859         this_arg_conv.inner = untag_ptr(this_arg);
45860         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45862         this_arg_conv.is_owned = false;
45863         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
45864         return ret_conv;
45865 }
45866
45867 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45868         LDKInvoiceFeatures this_arg_conv;
45869         this_arg_conv.inner = untag_ptr(this_arg);
45870         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45872         this_arg_conv.is_owned = false;
45873         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
45874         return ret_conv;
45875 }
45876
45877 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45878         LDKBolt12InvoiceFeatures this_arg_conv;
45879         this_arg_conv.inner = untag_ptr(this_arg);
45880         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45882         this_arg_conv.is_owned = false;
45883         jboolean ret_conv = Bolt12InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
45884         return ret_conv;
45885 }
45886
45887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45888         LDKInitFeatures this_arg_conv;
45889         this_arg_conv.inner = untag_ptr(this_arg);
45890         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45892         this_arg_conv.is_owned = false;
45893         InitFeatures_set_wumbo_optional(&this_arg_conv);
45894 }
45895
45896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45897         LDKInitFeatures this_arg_conv;
45898         this_arg_conv.inner = untag_ptr(this_arg);
45899         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45901         this_arg_conv.is_owned = false;
45902         InitFeatures_set_wumbo_required(&this_arg_conv);
45903 }
45904
45905 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
45906         LDKInitFeatures this_arg_conv;
45907         this_arg_conv.inner = untag_ptr(this_arg);
45908         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45910         this_arg_conv.is_owned = false;
45911         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
45912         return ret_conv;
45913 }
45914
45915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45916         LDKNodeFeatures this_arg_conv;
45917         this_arg_conv.inner = untag_ptr(this_arg);
45918         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45920         this_arg_conv.is_owned = false;
45921         NodeFeatures_set_wumbo_optional(&this_arg_conv);
45922 }
45923
45924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45925         LDKNodeFeatures this_arg_conv;
45926         this_arg_conv.inner = untag_ptr(this_arg);
45927         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45929         this_arg_conv.is_owned = false;
45930         NodeFeatures_set_wumbo_required(&this_arg_conv);
45931 }
45932
45933 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
45934         LDKNodeFeatures this_arg_conv;
45935         this_arg_conv.inner = untag_ptr(this_arg);
45936         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45938         this_arg_conv.is_owned = false;
45939         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
45940         return ret_conv;
45941 }
45942
45943 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
45944         LDKInitFeatures this_arg_conv;
45945         this_arg_conv.inner = untag_ptr(this_arg);
45946         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45948         this_arg_conv.is_owned = false;
45949         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
45950         return ret_conv;
45951 }
45952
45953 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
45954         LDKNodeFeatures this_arg_conv;
45955         this_arg_conv.inner = untag_ptr(this_arg);
45956         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45958         this_arg_conv.is_owned = false;
45959         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
45960         return ret_conv;
45961 }
45962
45963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45964         LDKInitFeatures this_arg_conv;
45965         this_arg_conv.inner = untag_ptr(this_arg);
45966         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45968         this_arg_conv.is_owned = false;
45969         InitFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
45970 }
45971
45972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45973         LDKInitFeatures this_arg_conv;
45974         this_arg_conv.inner = untag_ptr(this_arg);
45975         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45977         this_arg_conv.is_owned = false;
45978         InitFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
45979 }
45980
45981 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
45982         LDKInitFeatures this_arg_conv;
45983         this_arg_conv.inner = untag_ptr(this_arg);
45984         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45986         this_arg_conv.is_owned = false;
45987         jboolean ret_conv = InitFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
45988         return ret_conv;
45989 }
45990
45991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45992         LDKNodeFeatures this_arg_conv;
45993         this_arg_conv.inner = untag_ptr(this_arg);
45994         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45996         this_arg_conv.is_owned = false;
45997         NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
45998 }
45999
46000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46001         LDKNodeFeatures this_arg_conv;
46002         this_arg_conv.inner = untag_ptr(this_arg);
46003         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46005         this_arg_conv.is_owned = false;
46006         NodeFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
46007 }
46008
46009 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46010         LDKNodeFeatures this_arg_conv;
46011         this_arg_conv.inner = untag_ptr(this_arg);
46012         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46014         this_arg_conv.is_owned = false;
46015         jboolean ret_conv = NodeFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
46016         return ret_conv;
46017 }
46018
46019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46020         LDKChannelTypeFeatures this_arg_conv;
46021         this_arg_conv.inner = untag_ptr(this_arg);
46022         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46024         this_arg_conv.is_owned = false;
46025         ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
46026 }
46027
46028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46029         LDKChannelTypeFeatures this_arg_conv;
46030         this_arg_conv.inner = untag_ptr(this_arg);
46031         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46033         this_arg_conv.is_owned = false;
46034         ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
46035 }
46036
46037 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46038         LDKChannelTypeFeatures this_arg_conv;
46039         this_arg_conv.inner = untag_ptr(this_arg);
46040         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46042         this_arg_conv.is_owned = false;
46043         jboolean ret_conv = ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
46044         return ret_conv;
46045 }
46046
46047 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46048         LDKInitFeatures this_arg_conv;
46049         this_arg_conv.inner = untag_ptr(this_arg);
46050         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46052         this_arg_conv.is_owned = false;
46053         jboolean ret_conv = InitFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
46054         return ret_conv;
46055 }
46056
46057 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46058         LDKNodeFeatures this_arg_conv;
46059         this_arg_conv.inner = untag_ptr(this_arg);
46060         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46062         this_arg_conv.is_owned = false;
46063         jboolean ret_conv = NodeFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
46064         return ret_conv;
46065 }
46066
46067 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46068         LDKChannelTypeFeatures this_arg_conv;
46069         this_arg_conv.inner = untag_ptr(this_arg);
46070         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46072         this_arg_conv.is_owned = false;
46073         jboolean ret_conv = ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
46074         return ret_conv;
46075 }
46076
46077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46078         LDKInitFeatures this_arg_conv;
46079         this_arg_conv.inner = untag_ptr(this_arg);
46080         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46082         this_arg_conv.is_owned = false;
46083         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
46084 }
46085
46086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46087         LDKInitFeatures this_arg_conv;
46088         this_arg_conv.inner = untag_ptr(this_arg);
46089         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46091         this_arg_conv.is_owned = false;
46092         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
46093 }
46094
46095 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46096         LDKInitFeatures this_arg_conv;
46097         this_arg_conv.inner = untag_ptr(this_arg);
46098         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46100         this_arg_conv.is_owned = false;
46101         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
46102         return ret_conv;
46103 }
46104
46105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46106         LDKNodeFeatures this_arg_conv;
46107         this_arg_conv.inner = untag_ptr(this_arg);
46108         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46110         this_arg_conv.is_owned = false;
46111         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
46112 }
46113
46114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46115         LDKNodeFeatures this_arg_conv;
46116         this_arg_conv.inner = untag_ptr(this_arg);
46117         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46119         this_arg_conv.is_owned = false;
46120         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
46121 }
46122
46123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46124         LDKNodeFeatures this_arg_conv;
46125         this_arg_conv.inner = untag_ptr(this_arg);
46126         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46128         this_arg_conv.is_owned = false;
46129         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
46130         return ret_conv;
46131 }
46132
46133 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46134         LDKInitFeatures this_arg_conv;
46135         this_arg_conv.inner = untag_ptr(this_arg);
46136         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46138         this_arg_conv.is_owned = false;
46139         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
46140         return ret_conv;
46141 }
46142
46143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46144         LDKNodeFeatures this_arg_conv;
46145         this_arg_conv.inner = untag_ptr(this_arg);
46146         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46148         this_arg_conv.is_owned = false;
46149         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
46150         return ret_conv;
46151 }
46152
46153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46154         LDKInitFeatures this_arg_conv;
46155         this_arg_conv.inner = untag_ptr(this_arg);
46156         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46158         this_arg_conv.is_owned = false;
46159         InitFeatures_set_onion_messages_optional(&this_arg_conv);
46160 }
46161
46162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46163         LDKInitFeatures this_arg_conv;
46164         this_arg_conv.inner = untag_ptr(this_arg);
46165         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46167         this_arg_conv.is_owned = false;
46168         InitFeatures_set_onion_messages_required(&this_arg_conv);
46169 }
46170
46171 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46172         LDKInitFeatures this_arg_conv;
46173         this_arg_conv.inner = untag_ptr(this_arg);
46174         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46176         this_arg_conv.is_owned = false;
46177         jboolean ret_conv = InitFeatures_supports_onion_messages(&this_arg_conv);
46178         return ret_conv;
46179 }
46180
46181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46182         LDKNodeFeatures this_arg_conv;
46183         this_arg_conv.inner = untag_ptr(this_arg);
46184         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46186         this_arg_conv.is_owned = false;
46187         NodeFeatures_set_onion_messages_optional(&this_arg_conv);
46188 }
46189
46190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46191         LDKNodeFeatures this_arg_conv;
46192         this_arg_conv.inner = untag_ptr(this_arg);
46193         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46195         this_arg_conv.is_owned = false;
46196         NodeFeatures_set_onion_messages_required(&this_arg_conv);
46197 }
46198
46199 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46200         LDKNodeFeatures this_arg_conv;
46201         this_arg_conv.inner = untag_ptr(this_arg);
46202         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46204         this_arg_conv.is_owned = false;
46205         jboolean ret_conv = NodeFeatures_supports_onion_messages(&this_arg_conv);
46206         return ret_conv;
46207 }
46208
46209 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46210         LDKInitFeatures this_arg_conv;
46211         this_arg_conv.inner = untag_ptr(this_arg);
46212         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46214         this_arg_conv.is_owned = false;
46215         jboolean ret_conv = InitFeatures_requires_onion_messages(&this_arg_conv);
46216         return ret_conv;
46217 }
46218
46219 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46220         LDKNodeFeatures this_arg_conv;
46221         this_arg_conv.inner = untag_ptr(this_arg);
46222         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46224         this_arg_conv.is_owned = false;
46225         jboolean ret_conv = NodeFeatures_requires_onion_messages(&this_arg_conv);
46226         return ret_conv;
46227 }
46228
46229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46230         LDKInitFeatures this_arg_conv;
46231         this_arg_conv.inner = untag_ptr(this_arg);
46232         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46234         this_arg_conv.is_owned = false;
46235         InitFeatures_set_channel_type_optional(&this_arg_conv);
46236 }
46237
46238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46239         LDKInitFeatures this_arg_conv;
46240         this_arg_conv.inner = untag_ptr(this_arg);
46241         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46243         this_arg_conv.is_owned = false;
46244         InitFeatures_set_channel_type_required(&this_arg_conv);
46245 }
46246
46247 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46248         LDKInitFeatures this_arg_conv;
46249         this_arg_conv.inner = untag_ptr(this_arg);
46250         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46252         this_arg_conv.is_owned = false;
46253         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
46254         return ret_conv;
46255 }
46256
46257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46258         LDKNodeFeatures this_arg_conv;
46259         this_arg_conv.inner = untag_ptr(this_arg);
46260         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46262         this_arg_conv.is_owned = false;
46263         NodeFeatures_set_channel_type_optional(&this_arg_conv);
46264 }
46265
46266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46267         LDKNodeFeatures this_arg_conv;
46268         this_arg_conv.inner = untag_ptr(this_arg);
46269         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46271         this_arg_conv.is_owned = false;
46272         NodeFeatures_set_channel_type_required(&this_arg_conv);
46273 }
46274
46275 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46276         LDKNodeFeatures this_arg_conv;
46277         this_arg_conv.inner = untag_ptr(this_arg);
46278         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46280         this_arg_conv.is_owned = false;
46281         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
46282         return ret_conv;
46283 }
46284
46285 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46286         LDKInitFeatures this_arg_conv;
46287         this_arg_conv.inner = untag_ptr(this_arg);
46288         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46290         this_arg_conv.is_owned = false;
46291         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
46292         return ret_conv;
46293 }
46294
46295 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46296         LDKNodeFeatures this_arg_conv;
46297         this_arg_conv.inner = untag_ptr(this_arg);
46298         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46300         this_arg_conv.is_owned = false;
46301         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
46302         return ret_conv;
46303 }
46304
46305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46306         LDKInitFeatures this_arg_conv;
46307         this_arg_conv.inner = untag_ptr(this_arg);
46308         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46310         this_arg_conv.is_owned = false;
46311         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
46312 }
46313
46314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46315         LDKInitFeatures this_arg_conv;
46316         this_arg_conv.inner = untag_ptr(this_arg);
46317         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46319         this_arg_conv.is_owned = false;
46320         InitFeatures_set_scid_privacy_required(&this_arg_conv);
46321 }
46322
46323 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46324         LDKInitFeatures this_arg_conv;
46325         this_arg_conv.inner = untag_ptr(this_arg);
46326         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46328         this_arg_conv.is_owned = false;
46329         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
46330         return ret_conv;
46331 }
46332
46333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46334         LDKNodeFeatures this_arg_conv;
46335         this_arg_conv.inner = untag_ptr(this_arg);
46336         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46338         this_arg_conv.is_owned = false;
46339         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
46340 }
46341
46342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46343         LDKNodeFeatures this_arg_conv;
46344         this_arg_conv.inner = untag_ptr(this_arg);
46345         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46347         this_arg_conv.is_owned = false;
46348         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
46349 }
46350
46351 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46352         LDKNodeFeatures this_arg_conv;
46353         this_arg_conv.inner = untag_ptr(this_arg);
46354         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46356         this_arg_conv.is_owned = false;
46357         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
46358         return ret_conv;
46359 }
46360
46361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46362         LDKChannelTypeFeatures this_arg_conv;
46363         this_arg_conv.inner = untag_ptr(this_arg);
46364         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46366         this_arg_conv.is_owned = false;
46367         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
46368 }
46369
46370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46371         LDKChannelTypeFeatures this_arg_conv;
46372         this_arg_conv.inner = untag_ptr(this_arg);
46373         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46375         this_arg_conv.is_owned = false;
46376         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
46377 }
46378
46379 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46380         LDKChannelTypeFeatures this_arg_conv;
46381         this_arg_conv.inner = untag_ptr(this_arg);
46382         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46384         this_arg_conv.is_owned = false;
46385         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
46386         return ret_conv;
46387 }
46388
46389 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46390         LDKInitFeatures this_arg_conv;
46391         this_arg_conv.inner = untag_ptr(this_arg);
46392         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46394         this_arg_conv.is_owned = false;
46395         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
46396         return ret_conv;
46397 }
46398
46399 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46400         LDKNodeFeatures this_arg_conv;
46401         this_arg_conv.inner = untag_ptr(this_arg);
46402         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46404         this_arg_conv.is_owned = false;
46405         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
46406         return ret_conv;
46407 }
46408
46409 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46410         LDKChannelTypeFeatures this_arg_conv;
46411         this_arg_conv.inner = untag_ptr(this_arg);
46412         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46414         this_arg_conv.is_owned = false;
46415         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
46416         return ret_conv;
46417 }
46418
46419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46420         LDKInitFeatures this_arg_conv;
46421         this_arg_conv.inner = untag_ptr(this_arg);
46422         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46424         this_arg_conv.is_owned = false;
46425         InitFeatures_set_zero_conf_optional(&this_arg_conv);
46426 }
46427
46428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46429         LDKInitFeatures this_arg_conv;
46430         this_arg_conv.inner = untag_ptr(this_arg);
46431         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46433         this_arg_conv.is_owned = false;
46434         InitFeatures_set_zero_conf_required(&this_arg_conv);
46435 }
46436
46437 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46438         LDKInitFeatures this_arg_conv;
46439         this_arg_conv.inner = untag_ptr(this_arg);
46440         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46442         this_arg_conv.is_owned = false;
46443         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
46444         return ret_conv;
46445 }
46446
46447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46448         LDKNodeFeatures this_arg_conv;
46449         this_arg_conv.inner = untag_ptr(this_arg);
46450         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46452         this_arg_conv.is_owned = false;
46453         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
46454 }
46455
46456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46457         LDKNodeFeatures this_arg_conv;
46458         this_arg_conv.inner = untag_ptr(this_arg);
46459         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46461         this_arg_conv.is_owned = false;
46462         NodeFeatures_set_zero_conf_required(&this_arg_conv);
46463 }
46464
46465 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46466         LDKNodeFeatures this_arg_conv;
46467         this_arg_conv.inner = untag_ptr(this_arg);
46468         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46470         this_arg_conv.is_owned = false;
46471         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
46472         return ret_conv;
46473 }
46474
46475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46476         LDKChannelTypeFeatures this_arg_conv;
46477         this_arg_conv.inner = untag_ptr(this_arg);
46478         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46480         this_arg_conv.is_owned = false;
46481         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
46482 }
46483
46484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46485         LDKChannelTypeFeatures this_arg_conv;
46486         this_arg_conv.inner = untag_ptr(this_arg);
46487         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46489         this_arg_conv.is_owned = false;
46490         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
46491 }
46492
46493 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46494         LDKChannelTypeFeatures this_arg_conv;
46495         this_arg_conv.inner = untag_ptr(this_arg);
46496         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46498         this_arg_conv.is_owned = false;
46499         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
46500         return ret_conv;
46501 }
46502
46503 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46504         LDKInitFeatures this_arg_conv;
46505         this_arg_conv.inner = untag_ptr(this_arg);
46506         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46508         this_arg_conv.is_owned = false;
46509         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
46510         return ret_conv;
46511 }
46512
46513 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46514         LDKNodeFeatures this_arg_conv;
46515         this_arg_conv.inner = untag_ptr(this_arg);
46516         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46518         this_arg_conv.is_owned = false;
46519         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
46520         return ret_conv;
46521 }
46522
46523 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46524         LDKChannelTypeFeatures this_arg_conv;
46525         this_arg_conv.inner = untag_ptr(this_arg);
46526         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46528         this_arg_conv.is_owned = false;
46529         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
46530         return ret_conv;
46531 }
46532
46533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46534         LDKNodeFeatures this_arg_conv;
46535         this_arg_conv.inner = untag_ptr(this_arg);
46536         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46538         this_arg_conv.is_owned = false;
46539         NodeFeatures_set_keysend_optional(&this_arg_conv);
46540 }
46541
46542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46543         LDKNodeFeatures this_arg_conv;
46544         this_arg_conv.inner = untag_ptr(this_arg);
46545         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46547         this_arg_conv.is_owned = false;
46548         NodeFeatures_set_keysend_required(&this_arg_conv);
46549 }
46550
46551 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
46552         LDKNodeFeatures this_arg_conv;
46553         this_arg_conv.inner = untag_ptr(this_arg);
46554         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46556         this_arg_conv.is_owned = false;
46557         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
46558         return ret_conv;
46559 }
46560
46561 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
46562         LDKNodeFeatures this_arg_conv;
46563         this_arg_conv.inner = untag_ptr(this_arg);
46564         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46566         this_arg_conv.is_owned = false;
46567         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
46568         return ret_conv;
46569 }
46570
46571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46572         LDKShutdownScript this_obj_conv;
46573         this_obj_conv.inner = untag_ptr(this_obj);
46574         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46576         ShutdownScript_free(this_obj_conv);
46577 }
46578
46579 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
46580         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
46581         int64_t ret_ref = 0;
46582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46583         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46584         return ret_ref;
46585 }
46586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46587         LDKShutdownScript arg_conv;
46588         arg_conv.inner = untag_ptr(arg);
46589         arg_conv.is_owned = ptr_is_owned(arg);
46590         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46591         arg_conv.is_owned = false;
46592         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
46593         return ret_conv;
46594 }
46595
46596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46597         LDKShutdownScript orig_conv;
46598         orig_conv.inner = untag_ptr(orig);
46599         orig_conv.is_owned = ptr_is_owned(orig);
46600         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46601         orig_conv.is_owned = false;
46602         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
46603         int64_t ret_ref = 0;
46604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46605         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46606         return ret_ref;
46607 }
46608
46609 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46610         LDKShutdownScript a_conv;
46611         a_conv.inner = untag_ptr(a);
46612         a_conv.is_owned = ptr_is_owned(a);
46613         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46614         a_conv.is_owned = false;
46615         LDKShutdownScript b_conv;
46616         b_conv.inner = untag_ptr(b);
46617         b_conv.is_owned = ptr_is_owned(b);
46618         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46619         b_conv.is_owned = false;
46620         jboolean ret_conv = ShutdownScript_eq(&a_conv, &b_conv);
46621         return ret_conv;
46622 }
46623
46624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46625         LDKInvalidShutdownScript this_obj_conv;
46626         this_obj_conv.inner = untag_ptr(this_obj);
46627         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46629         InvalidShutdownScript_free(this_obj_conv);
46630 }
46631
46632 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
46633         LDKInvalidShutdownScript this_ptr_conv;
46634         this_ptr_conv.inner = untag_ptr(this_ptr);
46635         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46637         this_ptr_conv.is_owned = false;
46638         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
46639         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46640         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46641         return ret_arr;
46642 }
46643
46644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46645         LDKInvalidShutdownScript this_ptr_conv;
46646         this_ptr_conv.inner = untag_ptr(this_ptr);
46647         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46649         this_ptr_conv.is_owned = false;
46650         LDKCVec_u8Z val_ref;
46651         val_ref.datalen = (*env)->GetArrayLength(env, val);
46652         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
46653         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
46654         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
46655 }
46656
46657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
46658         LDKCVec_u8Z script_arg_ref;
46659         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
46660         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
46661         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
46662         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
46663         int64_t ret_ref = 0;
46664         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46665         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46666         return ret_ref;
46667 }
46668
46669 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
46670         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
46671         int64_t ret_ref = 0;
46672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46673         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46674         return ret_ref;
46675 }
46676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46677         LDKInvalidShutdownScript arg_conv;
46678         arg_conv.inner = untag_ptr(arg);
46679         arg_conv.is_owned = ptr_is_owned(arg);
46680         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46681         arg_conv.is_owned = false;
46682         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
46683         return ret_conv;
46684 }
46685
46686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46687         LDKInvalidShutdownScript orig_conv;
46688         orig_conv.inner = untag_ptr(orig);
46689         orig_conv.is_owned = ptr_is_owned(orig);
46690         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46691         orig_conv.is_owned = false;
46692         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
46693         int64_t ret_ref = 0;
46694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46695         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46696         return ret_ref;
46697 }
46698
46699 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
46700         LDKShutdownScript obj_conv;
46701         obj_conv.inner = untag_ptr(obj);
46702         obj_conv.is_owned = ptr_is_owned(obj);
46703         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46704         obj_conv.is_owned = false;
46705         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
46706         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46707         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46708         CVec_u8Z_free(ret_var);
46709         return ret_arr;
46710 }
46711
46712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46713         LDKu8slice ser_ref;
46714         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46715         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46716         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
46717         *ret_conv = ShutdownScript_read(ser_ref);
46718         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46719         return tag_ptr(ret_conv, true);
46720 }
46721
46722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
46723         uint8_t pubkey_hash_arr[20];
46724         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
46725         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
46726         uint8_t (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
46727         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
46728         int64_t ret_ref = 0;
46729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46730         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46731         return ret_ref;
46732 }
46733
46734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
46735         uint8_t script_hash_arr[32];
46736         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
46737         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
46738         uint8_t (*script_hash_ref)[32] = &script_hash_arr;
46739         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
46740         int64_t ret_ref = 0;
46741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46742         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46743         return ret_ref;
46744 }
46745
46746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
46747         
46748         LDKu8slice program_ref;
46749         program_ref.datalen = (*env)->GetArrayLength(env, program);
46750         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
46751         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
46752         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
46753         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
46754         return tag_ptr(ret_conv, true);
46755 }
46756
46757 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
46758         LDKShutdownScript this_arg_conv;
46759         this_arg_conv.inner = untag_ptr(this_arg);
46760         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46762         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
46763         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
46764         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46765         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46766         CVec_u8Z_free(ret_var);
46767         return ret_arr;
46768 }
46769
46770 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
46771         LDKShutdownScript this_arg_conv;
46772         this_arg_conv.inner = untag_ptr(this_arg);
46773         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46775         this_arg_conv.is_owned = false;
46776         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46777         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
46778         return ret_arr;
46779 }
46780
46781 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
46782         LDKShutdownScript this_arg_conv;
46783         this_arg_conv.inner = untag_ptr(this_arg);
46784         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46786         this_arg_conv.is_owned = false;
46787         LDKInitFeatures features_conv;
46788         features_conv.inner = untag_ptr(features);
46789         features_conv.is_owned = ptr_is_owned(features);
46790         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
46791         features_conv.is_owned = false;
46792         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
46793         return ret_conv;
46794 }
46795
46796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46797         if (!ptr_is_owned(this_ptr)) return;
46798         void* this_ptr_ptr = untag_ptr(this_ptr);
46799         CHECK_ACCESS(this_ptr_ptr);
46800         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
46801         FREE(untag_ptr(this_ptr));
46802         Retry_free(this_ptr_conv);
46803 }
46804
46805 static inline uint64_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
46806         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46807         *ret_copy = Retry_clone(arg);
46808         int64_t ret_ref = tag_ptr(ret_copy, true);
46809         return ret_ref;
46810 }
46811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46812         LDKRetry* arg_conv = (LDKRetry*)untag_ptr(arg);
46813         int64_t ret_conv = Retry_clone_ptr(arg_conv);
46814         return ret_conv;
46815 }
46816
46817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46818         LDKRetry* orig_conv = (LDKRetry*)untag_ptr(orig);
46819         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46820         *ret_copy = Retry_clone(orig_conv);
46821         int64_t ret_ref = tag_ptr(ret_copy, true);
46822         return ret_ref;
46823 }
46824
46825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
46826         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46827         *ret_copy = Retry_attempts(a);
46828         int64_t ret_ref = tag_ptr(ret_copy, true);
46829         return ret_ref;
46830 }
46831
46832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
46833         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46834         *ret_copy = Retry_timeout(a);
46835         int64_t ret_ref = tag_ptr(ret_copy, true);
46836         return ret_ref;
46837 }
46838
46839 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46840         LDKRetry* a_conv = (LDKRetry*)untag_ptr(a);
46841         LDKRetry* b_conv = (LDKRetry*)untag_ptr(b);
46842         jboolean ret_conv = Retry_eq(a_conv, b_conv);
46843         return ret_conv;
46844 }
46845
46846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
46847         LDKRetry* o_conv = (LDKRetry*)untag_ptr(o);
46848         int64_t ret_conv = Retry_hash(o_conv);
46849         return ret_conv;
46850 }
46851
46852 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46853         LDKRetryableSendFailure* orig_conv = (LDKRetryableSendFailure*)untag_ptr(orig);
46854         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_clone(orig_conv));
46855         return ret_conv;
46856 }
46857
46858 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1payment_1expired(JNIEnv *env, jclass clz) {
46859         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_payment_expired());
46860         return ret_conv;
46861 }
46862
46863 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1route_1not_1found(JNIEnv *env, jclass clz) {
46864         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_route_not_found());
46865         return ret_conv;
46866 }
46867
46868 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1duplicate_1payment(JNIEnv *env, jclass clz) {
46869         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_duplicate_payment());
46870         return ret_conv;
46871 }
46872
46873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46874         if (!ptr_is_owned(this_ptr)) return;
46875         void* this_ptr_ptr = untag_ptr(this_ptr);
46876         CHECK_ACCESS(this_ptr_ptr);
46877         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
46878         FREE(untag_ptr(this_ptr));
46879         PaymentSendFailure_free(this_ptr_conv);
46880 }
46881
46882 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
46883         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
46884         *ret_copy = PaymentSendFailure_clone(arg);
46885         int64_t ret_ref = tag_ptr(ret_copy, true);
46886         return ret_ref;
46887 }
46888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46889         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)untag_ptr(arg);
46890         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
46891         return ret_conv;
46892 }
46893
46894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46895         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)untag_ptr(orig);
46896         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
46897         *ret_copy = PaymentSendFailure_clone(orig_conv);
46898         int64_t ret_ref = tag_ptr(ret_copy, true);
46899         return ret_ref;
46900 }
46901
46902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
46903         void* a_ptr = untag_ptr(a);
46904         CHECK_ACCESS(a_ptr);
46905         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
46906         a_conv = APIError_clone((LDKAPIError*)untag_ptr(a));
46907         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
46908         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
46909         int64_t ret_ref = tag_ptr(ret_copy, true);
46910         return ret_ref;
46911 }
46912
46913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
46914         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
46915         a_constr.datalen = (*env)->GetArrayLength(env, a);
46916         if (a_constr.datalen > 0)
46917                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
46918         else
46919                 a_constr.data = NULL;
46920         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
46921         for (size_t w = 0; w < a_constr.datalen; w++) {
46922                 int64_t a_conv_22 = a_vals[w];
46923                 void* a_conv_22_ptr = untag_ptr(a_conv_22);
46924                 CHECK_ACCESS(a_conv_22_ptr);
46925                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
46926                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)untag_ptr(a_conv_22));
46927                 a_constr.data[w] = a_conv_22_conv;
46928         }
46929         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
46930         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
46931         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
46932         int64_t ret_ref = tag_ptr(ret_copy, true);
46933         return ret_ref;
46934 }
46935
46936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1resend_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
46937         LDKCVec_APIErrorZ a_constr;
46938         a_constr.datalen = (*env)->GetArrayLength(env, a);
46939         if (a_constr.datalen > 0)
46940                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
46941         else
46942                 a_constr.data = NULL;
46943         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
46944         for (size_t k = 0; k < a_constr.datalen; k++) {
46945                 int64_t a_conv_10 = a_vals[k];
46946                 void* a_conv_10_ptr = untag_ptr(a_conv_10);
46947                 CHECK_ACCESS(a_conv_10_ptr);
46948                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
46949                 a_conv_10_conv = APIError_clone((LDKAPIError*)untag_ptr(a_conv_10));
46950                 a_constr.data[k] = a_conv_10_conv;
46951         }
46952         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
46953         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
46954         *ret_copy = PaymentSendFailure_all_failed_resend_safe(a_constr);
46955         int64_t ret_ref = tag_ptr(ret_copy, true);
46956         return ret_ref;
46957 }
46958
46959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1duplicate_1payment(JNIEnv *env, jclass clz) {
46960         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
46961         *ret_copy = PaymentSendFailure_duplicate_payment();
46962         int64_t ret_ref = tag_ptr(ret_copy, true);
46963         return ret_ref;
46964 }
46965
46966 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) {
46967         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
46968         results_constr.datalen = (*env)->GetArrayLength(env, results);
46969         if (results_constr.datalen > 0)
46970                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
46971         else
46972                 results_constr.data = NULL;
46973         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
46974         for (size_t w = 0; w < results_constr.datalen; w++) {
46975                 int64_t results_conv_22 = results_vals[w];
46976                 void* results_conv_22_ptr = untag_ptr(results_conv_22);
46977                 CHECK_ACCESS(results_conv_22_ptr);
46978                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
46979                 results_constr.data[w] = results_conv_22_conv;
46980         }
46981         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
46982         LDKRouteParameters failed_paths_retry_conv;
46983         failed_paths_retry_conv.inner = untag_ptr(failed_paths_retry);
46984         failed_paths_retry_conv.is_owned = ptr_is_owned(failed_paths_retry);
46985         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
46986         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
46987         LDKThirtyTwoBytes payment_id_ref;
46988         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
46989         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
46990         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
46991         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
46992         int64_t ret_ref = tag_ptr(ret_copy, true);
46993         return ret_ref;
46994 }
46995
46996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46997         if (!ptr_is_owned(this_ptr)) return;
46998         void* this_ptr_ptr = untag_ptr(this_ptr);
46999         CHECK_ACCESS(this_ptr_ptr);
47000         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
47001         FREE(untag_ptr(this_ptr));
47002         CustomMessageReader_free(this_ptr_conv);
47003 }
47004
47005 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
47006         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
47007         *ret_ret = Type_clone(arg);
47008         return tag_ptr(ret_ret, true);
47009 }
47010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47011         void* arg_ptr = untag_ptr(arg);
47012         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
47013         LDKType* arg_conv = (LDKType*)arg_ptr;
47014         int64_t ret_conv = Type_clone_ptr(arg_conv);
47015         return ret_conv;
47016 }
47017
47018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47019         void* orig_ptr = untag_ptr(orig);
47020         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
47021         LDKType* orig_conv = (LDKType*)orig_ptr;
47022         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
47023         *ret_ret = Type_clone(orig_conv);
47024         return tag_ptr(ret_ret, true);
47025 }
47026
47027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47028         if (!ptr_is_owned(this_ptr)) return;
47029         void* this_ptr_ptr = untag_ptr(this_ptr);
47030         CHECK_ACCESS(this_ptr_ptr);
47031         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
47032         FREE(untag_ptr(this_ptr));
47033         Type_free(this_ptr_conv);
47034 }
47035
47036 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_UtxoLookupError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47037         LDKUtxoLookupError* orig_conv = (LDKUtxoLookupError*)untag_ptr(orig);
47038         jclass ret_conv = LDKUtxoLookupError_to_java(env, UtxoLookupError_clone(orig_conv));
47039         return ret_conv;
47040 }
47041
47042 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_UtxoLookupError_1unknown_1chain(JNIEnv *env, jclass clz) {
47043         jclass ret_conv = LDKUtxoLookupError_to_java(env, UtxoLookupError_unknown_chain());
47044         return ret_conv;
47045 }
47046
47047 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_UtxoLookupError_1unknown_1tx(JNIEnv *env, jclass clz) {
47048         jclass ret_conv = LDKUtxoLookupError_to_java(env, UtxoLookupError_unknown_tx());
47049         return ret_conv;
47050 }
47051
47052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoResult_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47053         if (!ptr_is_owned(this_ptr)) return;
47054         void* this_ptr_ptr = untag_ptr(this_ptr);
47055         CHECK_ACCESS(this_ptr_ptr);
47056         LDKUtxoResult this_ptr_conv = *(LDKUtxoResult*)(this_ptr_ptr);
47057         FREE(untag_ptr(this_ptr));
47058         UtxoResult_free(this_ptr_conv);
47059 }
47060
47061 static inline uint64_t UtxoResult_clone_ptr(LDKUtxoResult *NONNULL_PTR arg) {
47062         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
47063         *ret_copy = UtxoResult_clone(arg);
47064         int64_t ret_ref = tag_ptr(ret_copy, true);
47065         return ret_ref;
47066 }
47067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47068         LDKUtxoResult* arg_conv = (LDKUtxoResult*)untag_ptr(arg);
47069         int64_t ret_conv = UtxoResult_clone_ptr(arg_conv);
47070         return ret_conv;
47071 }
47072
47073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47074         LDKUtxoResult* orig_conv = (LDKUtxoResult*)untag_ptr(orig);
47075         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
47076         *ret_copy = UtxoResult_clone(orig_conv);
47077         int64_t ret_ref = tag_ptr(ret_copy, true);
47078         return ret_ref;
47079 }
47080
47081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1sync(JNIEnv *env, jclass clz, int64_t a) {
47082         void* a_ptr = untag_ptr(a);
47083         CHECK_ACCESS(a_ptr);
47084         LDKCResult_TxOutUtxoLookupErrorZ a_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(a_ptr);
47085         a_conv = CResult_TxOutUtxoLookupErrorZ_clone((LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(a));
47086         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
47087         *ret_copy = UtxoResult_sync(a_conv);
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_UtxoResult_1async(JNIEnv *env, jclass clz, int64_t a) {
47093         LDKUtxoFuture a_conv;
47094         a_conv.inner = untag_ptr(a);
47095         a_conv.is_owned = ptr_is_owned(a);
47096         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47097         a_conv = UtxoFuture_clone(&a_conv);
47098         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
47099         *ret_copy = UtxoResult_async(a_conv);
47100         int64_t ret_ref = tag_ptr(ret_copy, true);
47101         return ret_ref;
47102 }
47103
47104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoLookup_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47105         if (!ptr_is_owned(this_ptr)) return;
47106         void* this_ptr_ptr = untag_ptr(this_ptr);
47107         CHECK_ACCESS(this_ptr_ptr);
47108         LDKUtxoLookup this_ptr_conv = *(LDKUtxoLookup*)(this_ptr_ptr);
47109         FREE(untag_ptr(this_ptr));
47110         UtxoLookup_free(this_ptr_conv);
47111 }
47112
47113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47114         LDKUtxoFuture this_obj_conv;
47115         this_obj_conv.inner = untag_ptr(this_obj);
47116         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47118         UtxoFuture_free(this_obj_conv);
47119 }
47120
47121 static inline uint64_t UtxoFuture_clone_ptr(LDKUtxoFuture *NONNULL_PTR arg) {
47122         LDKUtxoFuture ret_var = UtxoFuture_clone(arg);
47123         int64_t ret_ref = 0;
47124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47125         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47126         return ret_ref;
47127 }
47128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47129         LDKUtxoFuture arg_conv;
47130         arg_conv.inner = untag_ptr(arg);
47131         arg_conv.is_owned = ptr_is_owned(arg);
47132         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47133         arg_conv.is_owned = false;
47134         int64_t ret_conv = UtxoFuture_clone_ptr(&arg_conv);
47135         return ret_conv;
47136 }
47137
47138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47139         LDKUtxoFuture orig_conv;
47140         orig_conv.inner = untag_ptr(orig);
47141         orig_conv.is_owned = ptr_is_owned(orig);
47142         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47143         orig_conv.is_owned = false;
47144         LDKUtxoFuture ret_var = UtxoFuture_clone(&orig_conv);
47145         int64_t ret_ref = 0;
47146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47147         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47148         return ret_ref;
47149 }
47150
47151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1new(JNIEnv *env, jclass clz) {
47152         LDKUtxoFuture ret_var = UtxoFuture_new();
47153         int64_t ret_ref = 0;
47154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47155         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47156         return ret_ref;
47157 }
47158
47159 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) {
47160         LDKUtxoFuture this_arg_conv;
47161         this_arg_conv.inner = untag_ptr(this_arg);
47162         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47164         this_arg_conv.is_owned = false;
47165         LDKNetworkGraph graph_conv;
47166         graph_conv.inner = untag_ptr(graph);
47167         graph_conv.is_owned = ptr_is_owned(graph);
47168         CHECK_INNER_FIELD_ACCESS_OR_NULL(graph_conv);
47169         graph_conv.is_owned = false;
47170         void* result_ptr = untag_ptr(result);
47171         CHECK_ACCESS(result_ptr);
47172         LDKCResult_TxOutUtxoLookupErrorZ result_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(result_ptr);
47173         UtxoFuture_resolve_without_forwarding(&this_arg_conv, &graph_conv, result_conv);
47174 }
47175
47176 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) {
47177         LDKUtxoFuture this_arg_conv;
47178         this_arg_conv.inner = untag_ptr(this_arg);
47179         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47181         this_arg_conv.is_owned = false;
47182         LDKNetworkGraph graph_conv;
47183         graph_conv.inner = untag_ptr(graph);
47184         graph_conv.is_owned = ptr_is_owned(graph);
47185         CHECK_INNER_FIELD_ACCESS_OR_NULL(graph_conv);
47186         graph_conv.is_owned = false;
47187         LDKP2PGossipSync gossip_conv;
47188         gossip_conv.inner = untag_ptr(gossip);
47189         gossip_conv.is_owned = ptr_is_owned(gossip);
47190         CHECK_INNER_FIELD_ACCESS_OR_NULL(gossip_conv);
47191         gossip_conv.is_owned = false;
47192         void* result_ptr = untag_ptr(result);
47193         CHECK_ACCESS(result_ptr);
47194         LDKCResult_TxOutUtxoLookupErrorZ result_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(result_ptr);
47195         UtxoFuture_resolve(&this_arg_conv, &graph_conv, &gossip_conv, result_conv);
47196 }
47197
47198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47199         LDKNodeId this_obj_conv;
47200         this_obj_conv.inner = untag_ptr(this_obj);
47201         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47203         NodeId_free(this_obj_conv);
47204 }
47205
47206 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
47207         LDKNodeId ret_var = NodeId_clone(arg);
47208         int64_t ret_ref = 0;
47209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47210         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47211         return ret_ref;
47212 }
47213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47214         LDKNodeId arg_conv;
47215         arg_conv.inner = untag_ptr(arg);
47216         arg_conv.is_owned = ptr_is_owned(arg);
47217         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47218         arg_conv.is_owned = false;
47219         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
47220         return ret_conv;
47221 }
47222
47223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47224         LDKNodeId orig_conv;
47225         orig_conv.inner = untag_ptr(orig);
47226         orig_conv.is_owned = ptr_is_owned(orig);
47227         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47228         orig_conv.is_owned = false;
47229         LDKNodeId ret_var = NodeId_clone(&orig_conv);
47230         int64_t ret_ref = 0;
47231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47232         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47233         return ret_ref;
47234 }
47235
47236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
47237         LDKPublicKey pubkey_ref;
47238         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
47239         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
47240         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
47241         int64_t ret_ref = 0;
47242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47243         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47244         return ret_ref;
47245 }
47246
47247 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
47248         LDKNodeId this_arg_conv;
47249         this_arg_conv.inner = untag_ptr(this_arg);
47250         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47252         this_arg_conv.is_owned = false;
47253         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
47254         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47255         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47256         return ret_arr;
47257 }
47258
47259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
47260         LDKNodeId o_conv;
47261         o_conv.inner = untag_ptr(o);
47262         o_conv.is_owned = ptr_is_owned(o);
47263         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47264         o_conv.is_owned = false;
47265         int64_t ret_conv = NodeId_hash(&o_conv);
47266         return ret_conv;
47267 }
47268
47269 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
47270         LDKNodeId obj_conv;
47271         obj_conv.inner = untag_ptr(obj);
47272         obj_conv.is_owned = ptr_is_owned(obj);
47273         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47274         obj_conv.is_owned = false;
47275         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
47276         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47277         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47278         CVec_u8Z_free(ret_var);
47279         return ret_arr;
47280 }
47281
47282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47283         LDKu8slice ser_ref;
47284         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47285         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47286         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
47287         *ret_conv = NodeId_read(ser_ref);
47288         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47289         return tag_ptr(ret_conv, true);
47290 }
47291
47292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47293         LDKNetworkGraph this_obj_conv;
47294         this_obj_conv.inner = untag_ptr(this_obj);
47295         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47297         NetworkGraph_free(this_obj_conv);
47298 }
47299
47300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47301         LDKReadOnlyNetworkGraph this_obj_conv;
47302         this_obj_conv.inner = untag_ptr(this_obj);
47303         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47305         ReadOnlyNetworkGraph_free(this_obj_conv);
47306 }
47307
47308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47309         if (!ptr_is_owned(this_ptr)) return;
47310         void* this_ptr_ptr = untag_ptr(this_ptr);
47311         CHECK_ACCESS(this_ptr_ptr);
47312         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
47313         FREE(untag_ptr(this_ptr));
47314         NetworkUpdate_free(this_ptr_conv);
47315 }
47316
47317 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
47318         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
47319         *ret_copy = NetworkUpdate_clone(arg);
47320         int64_t ret_ref = tag_ptr(ret_copy, true);
47321         return ret_ref;
47322 }
47323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47324         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)untag_ptr(arg);
47325         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
47326         return ret_conv;
47327 }
47328
47329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47330         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)untag_ptr(orig);
47331         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
47332         *ret_copy = NetworkUpdate_clone(orig_conv);
47333         int64_t ret_ref = tag_ptr(ret_copy, true);
47334         return ret_ref;
47335 }
47336
47337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
47338         LDKChannelUpdate msg_conv;
47339         msg_conv.inner = untag_ptr(msg);
47340         msg_conv.is_owned = ptr_is_owned(msg);
47341         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
47342         msg_conv = ChannelUpdate_clone(&msg_conv);
47343         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
47344         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
47345         int64_t ret_ref = tag_ptr(ret_copy, true);
47346         return ret_ref;
47347 }
47348
47349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
47350         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
47351         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
47352         int64_t ret_ref = tag_ptr(ret_copy, true);
47353         return ret_ref;
47354 }
47355
47356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
47357         LDKPublicKey node_id_ref;
47358         CHECK((*env)->GetArrayLength(env, node_id) == 33);
47359         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
47360         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
47361         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
47362         int64_t ret_ref = tag_ptr(ret_copy, true);
47363         return ret_ref;
47364 }
47365
47366 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47367         LDKNetworkUpdate* a_conv = (LDKNetworkUpdate*)untag_ptr(a);
47368         LDKNetworkUpdate* b_conv = (LDKNetworkUpdate*)untag_ptr(b);
47369         jboolean ret_conv = NetworkUpdate_eq(a_conv, b_conv);
47370         return ret_conv;
47371 }
47372
47373 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
47374         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)untag_ptr(obj);
47375         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
47376         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47377         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47378         CVec_u8Z_free(ret_var);
47379         return ret_arr;
47380 }
47381
47382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47383         LDKu8slice ser_ref;
47384         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47385         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47386         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
47387         *ret_conv = NetworkUpdate_read(ser_ref);
47388         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47389         return tag_ptr(ret_conv, true);
47390 }
47391
47392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47393         LDKP2PGossipSync this_obj_conv;
47394         this_obj_conv.inner = untag_ptr(this_obj);
47395         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47397         P2PGossipSync_free(this_obj_conv);
47398 }
47399
47400 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) {
47401         LDKNetworkGraph network_graph_conv;
47402         network_graph_conv.inner = untag_ptr(network_graph);
47403         network_graph_conv.is_owned = ptr_is_owned(network_graph);
47404         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
47405         network_graph_conv.is_owned = false;
47406         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
47407         CHECK_ACCESS(utxo_lookup_ptr);
47408         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
47409         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
47410         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
47411                 // Manually implement clone for Java trait instances
47412                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
47413                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47414                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
47415                 }
47416         }
47417         void* logger_ptr = untag_ptr(logger);
47418         CHECK_ACCESS(logger_ptr);
47419         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47420         if (logger_conv.free == LDKLogger_JCalls_free) {
47421                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47422                 LDKLogger_JCalls_cloned(&logger_conv);
47423         }
47424         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, utxo_lookup_conv, logger_conv);
47425         int64_t ret_ref = 0;
47426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47427         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47428         return ret_ref;
47429 }
47430
47431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1utxo_1lookup(JNIEnv *env, jclass clz, int64_t this_arg, int64_t utxo_lookup) {
47432         LDKP2PGossipSync this_arg_conv;
47433         this_arg_conv.inner = untag_ptr(this_arg);
47434         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47436         this_arg_conv.is_owned = false;
47437         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
47438         CHECK_ACCESS(utxo_lookup_ptr);
47439         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
47440         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
47441         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
47442                 // Manually implement clone for Java trait instances
47443                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
47444                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47445                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
47446                 }
47447         }
47448         P2PGossipSync_add_utxo_lookup(&this_arg_conv, utxo_lookup_conv);
47449 }
47450
47451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1handle_1network_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_update) {
47452         LDKNetworkGraph this_arg_conv;
47453         this_arg_conv.inner = untag_ptr(this_arg);
47454         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47456         this_arg_conv.is_owned = false;
47457         LDKNetworkUpdate* network_update_conv = (LDKNetworkUpdate*)untag_ptr(network_update);
47458         NetworkGraph_handle_network_update(&this_arg_conv, network_update_conv);
47459 }
47460
47461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
47462         LDKP2PGossipSync this_arg_conv;
47463         this_arg_conv.inner = untag_ptr(this_arg);
47464         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47466         this_arg_conv.is_owned = false;
47467         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
47468         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
47469         return tag_ptr(ret_ret, true);
47470 }
47471
47472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
47473         LDKP2PGossipSync this_arg_conv;
47474         this_arg_conv.inner = untag_ptr(this_arg);
47475         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47477         this_arg_conv.is_owned = false;
47478         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
47479         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
47480         return tag_ptr(ret_ret, true);
47481 }
47482
47483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47484         LDKChannelUpdateInfo this_obj_conv;
47485         this_obj_conv.inner = untag_ptr(this_obj);
47486         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47488         ChannelUpdateInfo_free(this_obj_conv);
47489 }
47490
47491 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
47492         LDKChannelUpdateInfo this_ptr_conv;
47493         this_ptr_conv.inner = untag_ptr(this_ptr);
47494         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47496         this_ptr_conv.is_owned = false;
47497         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
47498         return ret_conv;
47499 }
47500
47501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
47502         LDKChannelUpdateInfo this_ptr_conv;
47503         this_ptr_conv.inner = untag_ptr(this_ptr);
47504         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47506         this_ptr_conv.is_owned = false;
47507         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
47508 }
47509
47510 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
47511         LDKChannelUpdateInfo this_ptr_conv;
47512         this_ptr_conv.inner = untag_ptr(this_ptr);
47513         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47515         this_ptr_conv.is_owned = false;
47516         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
47517         return ret_conv;
47518 }
47519
47520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
47521         LDKChannelUpdateInfo this_ptr_conv;
47522         this_ptr_conv.inner = untag_ptr(this_ptr);
47523         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47525         this_ptr_conv.is_owned = false;
47526         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
47527 }
47528
47529 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
47530         LDKChannelUpdateInfo this_ptr_conv;
47531         this_ptr_conv.inner = untag_ptr(this_ptr);
47532         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47534         this_ptr_conv.is_owned = false;
47535         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
47536         return ret_conv;
47537 }
47538
47539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
47540         LDKChannelUpdateInfo this_ptr_conv;
47541         this_ptr_conv.inner = untag_ptr(this_ptr);
47542         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47544         this_ptr_conv.is_owned = false;
47545         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
47546 }
47547
47548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47549         LDKChannelUpdateInfo this_ptr_conv;
47550         this_ptr_conv.inner = untag_ptr(this_ptr);
47551         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47553         this_ptr_conv.is_owned = false;
47554         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
47555         return ret_conv;
47556 }
47557
47558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47559         LDKChannelUpdateInfo this_ptr_conv;
47560         this_ptr_conv.inner = untag_ptr(this_ptr);
47561         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47563         this_ptr_conv.is_owned = false;
47564         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
47565 }
47566
47567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47568         LDKChannelUpdateInfo this_ptr_conv;
47569         this_ptr_conv.inner = untag_ptr(this_ptr);
47570         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47572         this_ptr_conv.is_owned = false;
47573         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
47574         return ret_conv;
47575 }
47576
47577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47578         LDKChannelUpdateInfo this_ptr_conv;
47579         this_ptr_conv.inner = untag_ptr(this_ptr);
47580         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47582         this_ptr_conv.is_owned = false;
47583         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
47584 }
47585
47586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
47587         LDKChannelUpdateInfo this_ptr_conv;
47588         this_ptr_conv.inner = untag_ptr(this_ptr);
47589         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47591         this_ptr_conv.is_owned = false;
47592         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
47593         int64_t ret_ref = 0;
47594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47595         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47596         return ret_ref;
47597 }
47598
47599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47600         LDKChannelUpdateInfo this_ptr_conv;
47601         this_ptr_conv.inner = untag_ptr(this_ptr);
47602         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47604         this_ptr_conv.is_owned = false;
47605         LDKRoutingFees val_conv;
47606         val_conv.inner = untag_ptr(val);
47607         val_conv.is_owned = ptr_is_owned(val);
47608         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47609         val_conv = RoutingFees_clone(&val_conv);
47610         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
47611 }
47612
47613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
47614         LDKChannelUpdateInfo this_ptr_conv;
47615         this_ptr_conv.inner = untag_ptr(this_ptr);
47616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47618         this_ptr_conv.is_owned = false;
47619         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
47620         int64_t ret_ref = 0;
47621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47622         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47623         return ret_ref;
47624 }
47625
47626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47627         LDKChannelUpdateInfo this_ptr_conv;
47628         this_ptr_conv.inner = untag_ptr(this_ptr);
47629         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47631         this_ptr_conv.is_owned = false;
47632         LDKChannelUpdate val_conv;
47633         val_conv.inner = untag_ptr(val);
47634         val_conv.is_owned = ptr_is_owned(val);
47635         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47636         val_conv = ChannelUpdate_clone(&val_conv);
47637         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
47638 }
47639
47640 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) {
47641         LDKRoutingFees fees_arg_conv;
47642         fees_arg_conv.inner = untag_ptr(fees_arg);
47643         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
47644         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
47645         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
47646         LDKChannelUpdate last_update_message_arg_conv;
47647         last_update_message_arg_conv.inner = untag_ptr(last_update_message_arg);
47648         last_update_message_arg_conv.is_owned = ptr_is_owned(last_update_message_arg);
47649         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
47650         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
47651         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);
47652         int64_t ret_ref = 0;
47653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47654         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47655         return ret_ref;
47656 }
47657
47658 static inline uint64_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
47659         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
47660         int64_t ret_ref = 0;
47661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47662         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47663         return ret_ref;
47664 }
47665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47666         LDKChannelUpdateInfo arg_conv;
47667         arg_conv.inner = untag_ptr(arg);
47668         arg_conv.is_owned = ptr_is_owned(arg);
47669         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47670         arg_conv.is_owned = false;
47671         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
47672         return ret_conv;
47673 }
47674
47675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47676         LDKChannelUpdateInfo orig_conv;
47677         orig_conv.inner = untag_ptr(orig);
47678         orig_conv.is_owned = ptr_is_owned(orig);
47679         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47680         orig_conv.is_owned = false;
47681         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
47682         int64_t ret_ref = 0;
47683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47684         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47685         return ret_ref;
47686 }
47687
47688 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47689         LDKChannelUpdateInfo a_conv;
47690         a_conv.inner = untag_ptr(a);
47691         a_conv.is_owned = ptr_is_owned(a);
47692         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47693         a_conv.is_owned = false;
47694         LDKChannelUpdateInfo b_conv;
47695         b_conv.inner = untag_ptr(b);
47696         b_conv.is_owned = ptr_is_owned(b);
47697         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47698         b_conv.is_owned = false;
47699         jboolean ret_conv = ChannelUpdateInfo_eq(&a_conv, &b_conv);
47700         return ret_conv;
47701 }
47702
47703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
47704         LDKChannelUpdateInfo obj_conv;
47705         obj_conv.inner = untag_ptr(obj);
47706         obj_conv.is_owned = ptr_is_owned(obj);
47707         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47708         obj_conv.is_owned = false;
47709         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
47710         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47711         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47712         CVec_u8Z_free(ret_var);
47713         return ret_arr;
47714 }
47715
47716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47717         LDKu8slice ser_ref;
47718         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47719         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47720         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
47721         *ret_conv = ChannelUpdateInfo_read(ser_ref);
47722         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47723         return tag_ptr(ret_conv, true);
47724 }
47725
47726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47727         LDKChannelInfo this_obj_conv;
47728         this_obj_conv.inner = untag_ptr(this_obj);
47729         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47731         ChannelInfo_free(this_obj_conv);
47732 }
47733
47734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
47735         LDKChannelInfo this_ptr_conv;
47736         this_ptr_conv.inner = untag_ptr(this_ptr);
47737         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47739         this_ptr_conv.is_owned = false;
47740         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
47741         int64_t ret_ref = 0;
47742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47743         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47744         return ret_ref;
47745 }
47746
47747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47748         LDKChannelInfo this_ptr_conv;
47749         this_ptr_conv.inner = untag_ptr(this_ptr);
47750         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47752         this_ptr_conv.is_owned = false;
47753         LDKChannelFeatures val_conv;
47754         val_conv.inner = untag_ptr(val);
47755         val_conv.is_owned = ptr_is_owned(val);
47756         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47757         val_conv = ChannelFeatures_clone(&val_conv);
47758         ChannelInfo_set_features(&this_ptr_conv, val_conv);
47759 }
47760
47761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
47762         LDKChannelInfo this_ptr_conv;
47763         this_ptr_conv.inner = untag_ptr(this_ptr);
47764         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47766         this_ptr_conv.is_owned = false;
47767         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
47768         int64_t ret_ref = 0;
47769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47770         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47771         return ret_ref;
47772 }
47773
47774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47775         LDKChannelInfo this_ptr_conv;
47776         this_ptr_conv.inner = untag_ptr(this_ptr);
47777         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47779         this_ptr_conv.is_owned = false;
47780         LDKNodeId val_conv;
47781         val_conv.inner = untag_ptr(val);
47782         val_conv.is_owned = ptr_is_owned(val);
47783         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47784         val_conv = NodeId_clone(&val_conv);
47785         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
47786 }
47787
47788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
47789         LDKChannelInfo this_ptr_conv;
47790         this_ptr_conv.inner = untag_ptr(this_ptr);
47791         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47793         this_ptr_conv.is_owned = false;
47794         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
47795         int64_t ret_ref = 0;
47796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47798         return ret_ref;
47799 }
47800
47801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47802         LDKChannelInfo this_ptr_conv;
47803         this_ptr_conv.inner = untag_ptr(this_ptr);
47804         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47806         this_ptr_conv.is_owned = false;
47807         LDKChannelUpdateInfo val_conv;
47808         val_conv.inner = untag_ptr(val);
47809         val_conv.is_owned = ptr_is_owned(val);
47810         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47811         val_conv = ChannelUpdateInfo_clone(&val_conv);
47812         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
47813 }
47814
47815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
47816         LDKChannelInfo this_ptr_conv;
47817         this_ptr_conv.inner = untag_ptr(this_ptr);
47818         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47820         this_ptr_conv.is_owned = false;
47821         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
47822         int64_t ret_ref = 0;
47823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47824         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47825         return ret_ref;
47826 }
47827
47828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47829         LDKChannelInfo this_ptr_conv;
47830         this_ptr_conv.inner = untag_ptr(this_ptr);
47831         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47833         this_ptr_conv.is_owned = false;
47834         LDKNodeId val_conv;
47835         val_conv.inner = untag_ptr(val);
47836         val_conv.is_owned = ptr_is_owned(val);
47837         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47838         val_conv = NodeId_clone(&val_conv);
47839         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
47840 }
47841
47842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
47843         LDKChannelInfo this_ptr_conv;
47844         this_ptr_conv.inner = untag_ptr(this_ptr);
47845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47847         this_ptr_conv.is_owned = false;
47848         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_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 void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47856         LDKChannelInfo this_ptr_conv;
47857         this_ptr_conv.inner = untag_ptr(this_ptr);
47858         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47860         this_ptr_conv.is_owned = false;
47861         LDKChannelUpdateInfo val_conv;
47862         val_conv.inner = untag_ptr(val);
47863         val_conv.is_owned = ptr_is_owned(val);
47864         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47865         val_conv = ChannelUpdateInfo_clone(&val_conv);
47866         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
47867 }
47868
47869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
47870         LDKChannelInfo this_ptr_conv;
47871         this_ptr_conv.inner = untag_ptr(this_ptr);
47872         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47874         this_ptr_conv.is_owned = false;
47875         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47876         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
47877         int64_t ret_ref = tag_ptr(ret_copy, true);
47878         return ret_ref;
47879 }
47880
47881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47882         LDKChannelInfo this_ptr_conv;
47883         this_ptr_conv.inner = untag_ptr(this_ptr);
47884         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47886         this_ptr_conv.is_owned = false;
47887         void* val_ptr = untag_ptr(val);
47888         CHECK_ACCESS(val_ptr);
47889         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
47890         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
47891         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
47892 }
47893
47894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
47895         LDKChannelInfo this_ptr_conv;
47896         this_ptr_conv.inner = untag_ptr(this_ptr);
47897         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47899         this_ptr_conv.is_owned = false;
47900         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
47901         int64_t ret_ref = 0;
47902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47903         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47904         return ret_ref;
47905 }
47906
47907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47908         LDKChannelInfo this_ptr_conv;
47909         this_ptr_conv.inner = untag_ptr(this_ptr);
47910         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47912         this_ptr_conv.is_owned = false;
47913         LDKChannelAnnouncement val_conv;
47914         val_conv.inner = untag_ptr(val);
47915         val_conv.is_owned = ptr_is_owned(val);
47916         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47917         val_conv = ChannelAnnouncement_clone(&val_conv);
47918         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
47919 }
47920
47921 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
47922         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
47923         int64_t ret_ref = 0;
47924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47925         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47926         return ret_ref;
47927 }
47928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47929         LDKChannelInfo arg_conv;
47930         arg_conv.inner = untag_ptr(arg);
47931         arg_conv.is_owned = ptr_is_owned(arg);
47932         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47933         arg_conv.is_owned = false;
47934         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
47935         return ret_conv;
47936 }
47937
47938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47939         LDKChannelInfo orig_conv;
47940         orig_conv.inner = untag_ptr(orig);
47941         orig_conv.is_owned = ptr_is_owned(orig);
47942         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47943         orig_conv.is_owned = false;
47944         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
47945         int64_t ret_ref = 0;
47946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47947         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47948         return ret_ref;
47949 }
47950
47951 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47952         LDKChannelInfo a_conv;
47953         a_conv.inner = untag_ptr(a);
47954         a_conv.is_owned = ptr_is_owned(a);
47955         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47956         a_conv.is_owned = false;
47957         LDKChannelInfo b_conv;
47958         b_conv.inner = untag_ptr(b);
47959         b_conv.is_owned = ptr_is_owned(b);
47960         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47961         b_conv.is_owned = false;
47962         jboolean ret_conv = ChannelInfo_eq(&a_conv, &b_conv);
47963         return ret_conv;
47964 }
47965
47966 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) {
47967         LDKChannelInfo this_arg_conv;
47968         this_arg_conv.inner = untag_ptr(this_arg);
47969         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47971         this_arg_conv.is_owned = false;
47972         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
47973         int64_t ret_ref = 0;
47974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47975         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47976         return ret_ref;
47977 }
47978
47979 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
47980         LDKChannelInfo obj_conv;
47981         obj_conv.inner = untag_ptr(obj);
47982         obj_conv.is_owned = ptr_is_owned(obj);
47983         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47984         obj_conv.is_owned = false;
47985         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
47986         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47987         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47988         CVec_u8Z_free(ret_var);
47989         return ret_arr;
47990 }
47991
47992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47993         LDKu8slice ser_ref;
47994         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47995         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47996         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
47997         *ret_conv = ChannelInfo_read(ser_ref);
47998         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47999         return tag_ptr(ret_conv, true);
48000 }
48001
48002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48003         LDKDirectedChannelInfo this_obj_conv;
48004         this_obj_conv.inner = untag_ptr(this_obj);
48005         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48007         DirectedChannelInfo_free(this_obj_conv);
48008 }
48009
48010 static inline uint64_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
48011         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
48012         int64_t ret_ref = 0;
48013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48014         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48015         return ret_ref;
48016 }
48017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48018         LDKDirectedChannelInfo arg_conv;
48019         arg_conv.inner = untag_ptr(arg);
48020         arg_conv.is_owned = ptr_is_owned(arg);
48021         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48022         arg_conv.is_owned = false;
48023         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
48024         return ret_conv;
48025 }
48026
48027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48028         LDKDirectedChannelInfo orig_conv;
48029         orig_conv.inner = untag_ptr(orig);
48030         orig_conv.is_owned = ptr_is_owned(orig);
48031         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48032         orig_conv.is_owned = false;
48033         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
48034         int64_t ret_ref = 0;
48035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48036         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48037         return ret_ref;
48038 }
48039
48040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
48041         LDKDirectedChannelInfo this_arg_conv;
48042         this_arg_conv.inner = untag_ptr(this_arg);
48043         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48045         this_arg_conv.is_owned = false;
48046         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
48047         int64_t ret_ref = 0;
48048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48050         return ret_ref;
48051 }
48052
48053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
48054         LDKDirectedChannelInfo this_arg_conv;
48055         this_arg_conv.inner = untag_ptr(this_arg);
48056         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48058         this_arg_conv.is_owned = false;
48059         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
48060         return ret_conv;
48061 }
48062
48063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
48064         LDKDirectedChannelInfo this_arg_conv;
48065         this_arg_conv.inner = untag_ptr(this_arg);
48066         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48068         this_arg_conv.is_owned = false;
48069         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
48070         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
48071         int64_t ret_ref = tag_ptr(ret_copy, true);
48072         return ret_ref;
48073 }
48074
48075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48076         if (!ptr_is_owned(this_ptr)) return;
48077         void* this_ptr_ptr = untag_ptr(this_ptr);
48078         CHECK_ACCESS(this_ptr_ptr);
48079         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
48080         FREE(untag_ptr(this_ptr));
48081         EffectiveCapacity_free(this_ptr_conv);
48082 }
48083
48084 static inline uint64_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
48085         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
48086         *ret_copy = EffectiveCapacity_clone(arg);
48087         int64_t ret_ref = tag_ptr(ret_copy, true);
48088         return ret_ref;
48089 }
48090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48091         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)untag_ptr(arg);
48092         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
48093         return ret_conv;
48094 }
48095
48096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48097         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)untag_ptr(orig);
48098         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
48099         *ret_copy = EffectiveCapacity_clone(orig_conv);
48100         int64_t ret_ref = tag_ptr(ret_copy, true);
48101         return ret_ref;
48102 }
48103
48104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
48105         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
48106         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
48107         int64_t ret_ref = tag_ptr(ret_copy, true);
48108         return ret_ref;
48109 }
48110
48111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
48112         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
48113         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
48114         int64_t ret_ref = tag_ptr(ret_copy, true);
48115         return ret_ref;
48116 }
48117
48118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
48119         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
48120         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat);
48121         int64_t ret_ref = tag_ptr(ret_copy, true);
48122         return ret_ref;
48123 }
48124
48125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
48126         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
48127         *ret_copy = EffectiveCapacity_infinite();
48128         int64_t ret_ref = tag_ptr(ret_copy, true);
48129         return ret_ref;
48130 }
48131
48132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
48133         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
48134         *ret_copy = EffectiveCapacity_unknown();
48135         int64_t ret_ref = tag_ptr(ret_copy, true);
48136         return ret_ref;
48137 }
48138
48139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
48140         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)untag_ptr(this_arg);
48141         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
48142         return ret_conv;
48143 }
48144
48145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48146         LDKRoutingFees this_obj_conv;
48147         this_obj_conv.inner = untag_ptr(this_obj);
48148         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48150         RoutingFees_free(this_obj_conv);
48151 }
48152
48153 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48154         LDKRoutingFees this_ptr_conv;
48155         this_ptr_conv.inner = untag_ptr(this_ptr);
48156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48158         this_ptr_conv.is_owned = false;
48159         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
48160         return ret_conv;
48161 }
48162
48163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
48164         LDKRoutingFees this_ptr_conv;
48165         this_ptr_conv.inner = untag_ptr(this_ptr);
48166         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48168         this_ptr_conv.is_owned = false;
48169         RoutingFees_set_base_msat(&this_ptr_conv, val);
48170 }
48171
48172 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
48173         LDKRoutingFees this_ptr_conv;
48174         this_ptr_conv.inner = untag_ptr(this_ptr);
48175         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48177         this_ptr_conv.is_owned = false;
48178         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
48179         return ret_conv;
48180 }
48181
48182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
48183         LDKRoutingFees this_ptr_conv;
48184         this_ptr_conv.inner = untag_ptr(this_ptr);
48185         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48187         this_ptr_conv.is_owned = false;
48188         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
48189 }
48190
48191 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) {
48192         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
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 jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48200         LDKRoutingFees a_conv;
48201         a_conv.inner = untag_ptr(a);
48202         a_conv.is_owned = ptr_is_owned(a);
48203         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48204         a_conv.is_owned = false;
48205         LDKRoutingFees b_conv;
48206         b_conv.inner = untag_ptr(b);
48207         b_conv.is_owned = ptr_is_owned(b);
48208         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48209         b_conv.is_owned = false;
48210         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
48211         return ret_conv;
48212 }
48213
48214 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
48215         LDKRoutingFees ret_var = RoutingFees_clone(arg);
48216         int64_t ret_ref = 0;
48217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48218         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48219         return ret_ref;
48220 }
48221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48222         LDKRoutingFees arg_conv;
48223         arg_conv.inner = untag_ptr(arg);
48224         arg_conv.is_owned = ptr_is_owned(arg);
48225         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48226         arg_conv.is_owned = false;
48227         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
48228         return ret_conv;
48229 }
48230
48231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48232         LDKRoutingFees orig_conv;
48233         orig_conv.inner = untag_ptr(orig);
48234         orig_conv.is_owned = ptr_is_owned(orig);
48235         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48236         orig_conv.is_owned = false;
48237         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
48238         int64_t ret_ref = 0;
48239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48240         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48241         return ret_ref;
48242 }
48243
48244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
48245         LDKRoutingFees o_conv;
48246         o_conv.inner = untag_ptr(o);
48247         o_conv.is_owned = ptr_is_owned(o);
48248         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48249         o_conv.is_owned = false;
48250         int64_t ret_conv = RoutingFees_hash(&o_conv);
48251         return ret_conv;
48252 }
48253
48254 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
48255         LDKRoutingFees obj_conv;
48256         obj_conv.inner = untag_ptr(obj);
48257         obj_conv.is_owned = ptr_is_owned(obj);
48258         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48259         obj_conv.is_owned = false;
48260         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
48261         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48262         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48263         CVec_u8Z_free(ret_var);
48264         return ret_arr;
48265 }
48266
48267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48268         LDKu8slice ser_ref;
48269         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48270         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48271         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
48272         *ret_conv = RoutingFees_read(ser_ref);
48273         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48274         return tag_ptr(ret_conv, true);
48275 }
48276
48277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48278         LDKNodeAnnouncementInfo this_obj_conv;
48279         this_obj_conv.inner = untag_ptr(this_obj);
48280         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48282         NodeAnnouncementInfo_free(this_obj_conv);
48283 }
48284
48285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
48286         LDKNodeAnnouncementInfo this_ptr_conv;
48287         this_ptr_conv.inner = untag_ptr(this_ptr);
48288         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48290         this_ptr_conv.is_owned = false;
48291         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
48292         int64_t ret_ref = 0;
48293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48294         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48295         return ret_ref;
48296 }
48297
48298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48299         LDKNodeAnnouncementInfo this_ptr_conv;
48300         this_ptr_conv.inner = untag_ptr(this_ptr);
48301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48303         this_ptr_conv.is_owned = false;
48304         LDKNodeFeatures val_conv;
48305         val_conv.inner = untag_ptr(val);
48306         val_conv.is_owned = ptr_is_owned(val);
48307         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48308         val_conv = NodeFeatures_clone(&val_conv);
48309         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
48310 }
48311
48312 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
48313         LDKNodeAnnouncementInfo this_ptr_conv;
48314         this_ptr_conv.inner = untag_ptr(this_ptr);
48315         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48317         this_ptr_conv.is_owned = false;
48318         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
48319         return ret_conv;
48320 }
48321
48322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
48323         LDKNodeAnnouncementInfo this_ptr_conv;
48324         this_ptr_conv.inner = untag_ptr(this_ptr);
48325         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48327         this_ptr_conv.is_owned = false;
48328         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
48329 }
48330
48331 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
48332         LDKNodeAnnouncementInfo this_ptr_conv;
48333         this_ptr_conv.inner = untag_ptr(this_ptr);
48334         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48336         this_ptr_conv.is_owned = false;
48337         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
48338         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
48339         return ret_arr;
48340 }
48341
48342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
48343         LDKNodeAnnouncementInfo this_ptr_conv;
48344         this_ptr_conv.inner = untag_ptr(this_ptr);
48345         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48347         this_ptr_conv.is_owned = false;
48348         LDKThreeBytes val_ref;
48349         CHECK((*env)->GetArrayLength(env, val) == 3);
48350         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
48351         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
48352 }
48353
48354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
48355         LDKNodeAnnouncementInfo this_ptr_conv;
48356         this_ptr_conv.inner = untag_ptr(this_ptr);
48357         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48359         this_ptr_conv.is_owned = false;
48360         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
48361         int64_t ret_ref = 0;
48362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48363         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48364         return ret_ref;
48365 }
48366
48367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48368         LDKNodeAnnouncementInfo this_ptr_conv;
48369         this_ptr_conv.inner = untag_ptr(this_ptr);
48370         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48372         this_ptr_conv.is_owned = false;
48373         LDKNodeAlias val_conv;
48374         val_conv.inner = untag_ptr(val);
48375         val_conv.is_owned = ptr_is_owned(val);
48376         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48377         val_conv = NodeAlias_clone(&val_conv);
48378         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
48379 }
48380
48381 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
48382         LDKNodeAnnouncementInfo this_ptr_conv;
48383         this_ptr_conv.inner = untag_ptr(this_ptr);
48384         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48386         this_ptr_conv.is_owned = false;
48387         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_get_addresses(&this_ptr_conv);
48388         int64_tArray ret_arr = NULL;
48389         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48390         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48391         for (size_t m = 0; m < ret_var.datalen; m++) {
48392                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
48393                 *ret_conv_12_copy = ret_var.data[m];
48394                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
48395                 ret_arr_ptr[m] = ret_conv_12_ref;
48396         }
48397         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48398         FREE(ret_var.data);
48399         return ret_arr;
48400 }
48401
48402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
48403         LDKNodeAnnouncementInfo this_ptr_conv;
48404         this_ptr_conv.inner = untag_ptr(this_ptr);
48405         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48407         this_ptr_conv.is_owned = false;
48408         LDKCVec_NetAddressZ val_constr;
48409         val_constr.datalen = (*env)->GetArrayLength(env, val);
48410         if (val_constr.datalen > 0)
48411                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
48412         else
48413                 val_constr.data = NULL;
48414         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
48415         for (size_t m = 0; m < val_constr.datalen; m++) {
48416                 int64_t val_conv_12 = val_vals[m];
48417                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
48418                 CHECK_ACCESS(val_conv_12_ptr);
48419                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
48420                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
48421                 val_constr.data[m] = val_conv_12_conv;
48422         }
48423         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
48424         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
48425 }
48426
48427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
48428         LDKNodeAnnouncementInfo this_ptr_conv;
48429         this_ptr_conv.inner = untag_ptr(this_ptr);
48430         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48432         this_ptr_conv.is_owned = false;
48433         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
48434         int64_t ret_ref = 0;
48435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48436         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48437         return ret_ref;
48438 }
48439
48440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48441         LDKNodeAnnouncementInfo this_ptr_conv;
48442         this_ptr_conv.inner = untag_ptr(this_ptr);
48443         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48445         this_ptr_conv.is_owned = false;
48446         LDKNodeAnnouncement val_conv;
48447         val_conv.inner = untag_ptr(val);
48448         val_conv.is_owned = ptr_is_owned(val);
48449         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48450         val_conv = NodeAnnouncement_clone(&val_conv);
48451         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
48452 }
48453
48454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int64_t alias_arg, int64_tArray addresses_arg, int64_t announcement_message_arg) {
48455         LDKNodeFeatures features_arg_conv;
48456         features_arg_conv.inner = untag_ptr(features_arg);
48457         features_arg_conv.is_owned = ptr_is_owned(features_arg);
48458         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
48459         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
48460         LDKThreeBytes rgb_arg_ref;
48461         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
48462         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
48463         LDKNodeAlias alias_arg_conv;
48464         alias_arg_conv.inner = untag_ptr(alias_arg);
48465         alias_arg_conv.is_owned = ptr_is_owned(alias_arg);
48466         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
48467         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
48468         LDKCVec_NetAddressZ addresses_arg_constr;
48469         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
48470         if (addresses_arg_constr.datalen > 0)
48471                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
48472         else
48473                 addresses_arg_constr.data = NULL;
48474         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
48475         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
48476                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
48477                 void* addresses_arg_conv_12_ptr = untag_ptr(addresses_arg_conv_12);
48478                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
48479                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
48480                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
48481         }
48482         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
48483         LDKNodeAnnouncement announcement_message_arg_conv;
48484         announcement_message_arg_conv.inner = untag_ptr(announcement_message_arg);
48485         announcement_message_arg_conv.is_owned = ptr_is_owned(announcement_message_arg);
48486         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
48487         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
48488         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
48489         int64_t ret_ref = 0;
48490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48491         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48492         return ret_ref;
48493 }
48494
48495 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
48496         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
48497         int64_t ret_ref = 0;
48498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48499         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48500         return ret_ref;
48501 }
48502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48503         LDKNodeAnnouncementInfo arg_conv;
48504         arg_conv.inner = untag_ptr(arg);
48505         arg_conv.is_owned = ptr_is_owned(arg);
48506         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48507         arg_conv.is_owned = false;
48508         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
48509         return ret_conv;
48510 }
48511
48512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48513         LDKNodeAnnouncementInfo orig_conv;
48514         orig_conv.inner = untag_ptr(orig);
48515         orig_conv.is_owned = ptr_is_owned(orig);
48516         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48517         orig_conv.is_owned = false;
48518         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
48519         int64_t ret_ref = 0;
48520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48521         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48522         return ret_ref;
48523 }
48524
48525 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48526         LDKNodeAnnouncementInfo a_conv;
48527         a_conv.inner = untag_ptr(a);
48528         a_conv.is_owned = ptr_is_owned(a);
48529         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48530         a_conv.is_owned = false;
48531         LDKNodeAnnouncementInfo b_conv;
48532         b_conv.inner = untag_ptr(b);
48533         b_conv.is_owned = ptr_is_owned(b);
48534         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48535         b_conv.is_owned = false;
48536         jboolean ret_conv = NodeAnnouncementInfo_eq(&a_conv, &b_conv);
48537         return ret_conv;
48538 }
48539
48540 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
48541         LDKNodeAnnouncementInfo obj_conv;
48542         obj_conv.inner = untag_ptr(obj);
48543         obj_conv.is_owned = ptr_is_owned(obj);
48544         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48545         obj_conv.is_owned = false;
48546         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
48547         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48548         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48549         CVec_u8Z_free(ret_var);
48550         return ret_arr;
48551 }
48552
48553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48554         LDKu8slice ser_ref;
48555         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48556         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48557         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
48558         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
48559         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48560         return tag_ptr(ret_conv, true);
48561 }
48562
48563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48564         LDKNodeAlias this_obj_conv;
48565         this_obj_conv.inner = untag_ptr(this_obj);
48566         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48568         NodeAlias_free(this_obj_conv);
48569 }
48570
48571 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
48572         LDKNodeAlias this_ptr_conv;
48573         this_ptr_conv.inner = untag_ptr(this_ptr);
48574         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48576         this_ptr_conv.is_owned = false;
48577         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48578         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
48579         return ret_arr;
48580 }
48581
48582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
48583         LDKNodeAlias this_ptr_conv;
48584         this_ptr_conv.inner = untag_ptr(this_ptr);
48585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48587         this_ptr_conv.is_owned = false;
48588         LDKThirtyTwoBytes val_ref;
48589         CHECK((*env)->GetArrayLength(env, val) == 32);
48590         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
48591         NodeAlias_set_a(&this_ptr_conv, val_ref);
48592 }
48593
48594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
48595         LDKThirtyTwoBytes a_arg_ref;
48596         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
48597         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
48598         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
48599         int64_t ret_ref = 0;
48600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48601         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48602         return ret_ref;
48603 }
48604
48605 static inline uint64_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
48606         LDKNodeAlias ret_var = NodeAlias_clone(arg);
48607         int64_t ret_ref = 0;
48608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48609         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48610         return ret_ref;
48611 }
48612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48613         LDKNodeAlias arg_conv;
48614         arg_conv.inner = untag_ptr(arg);
48615         arg_conv.is_owned = ptr_is_owned(arg);
48616         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48617         arg_conv.is_owned = false;
48618         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
48619         return ret_conv;
48620 }
48621
48622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48623         LDKNodeAlias orig_conv;
48624         orig_conv.inner = untag_ptr(orig);
48625         orig_conv.is_owned = ptr_is_owned(orig);
48626         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48627         orig_conv.is_owned = false;
48628         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
48629         int64_t ret_ref = 0;
48630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48631         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48632         return ret_ref;
48633 }
48634
48635 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAlias_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48636         LDKNodeAlias a_conv;
48637         a_conv.inner = untag_ptr(a);
48638         a_conv.is_owned = ptr_is_owned(a);
48639         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48640         a_conv.is_owned = false;
48641         LDKNodeAlias b_conv;
48642         b_conv.inner = untag_ptr(b);
48643         b_conv.is_owned = ptr_is_owned(b);
48644         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48645         b_conv.is_owned = false;
48646         jboolean ret_conv = NodeAlias_eq(&a_conv, &b_conv);
48647         return ret_conv;
48648 }
48649
48650 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
48651         LDKNodeAlias obj_conv;
48652         obj_conv.inner = untag_ptr(obj);
48653         obj_conv.is_owned = ptr_is_owned(obj);
48654         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48655         obj_conv.is_owned = false;
48656         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
48657         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48658         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48659         CVec_u8Z_free(ret_var);
48660         return ret_arr;
48661 }
48662
48663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48664         LDKu8slice ser_ref;
48665         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48666         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48667         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
48668         *ret_conv = NodeAlias_read(ser_ref);
48669         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48670         return tag_ptr(ret_conv, true);
48671 }
48672
48673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48674         LDKNodeInfo this_obj_conv;
48675         this_obj_conv.inner = untag_ptr(this_obj);
48676         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48678         NodeInfo_free(this_obj_conv);
48679 }
48680
48681 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
48682         LDKNodeInfo this_ptr_conv;
48683         this_ptr_conv.inner = untag_ptr(this_ptr);
48684         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48686         this_ptr_conv.is_owned = false;
48687         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
48688         int64_tArray ret_arr = NULL;
48689         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48690         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48691         for (size_t g = 0; g < ret_var.datalen; g++) {
48692                 int64_t ret_conv_6_conv = ret_var.data[g];
48693                 ret_arr_ptr[g] = ret_conv_6_conv;
48694         }
48695         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48696         FREE(ret_var.data);
48697         return ret_arr;
48698 }
48699
48700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
48701         LDKNodeInfo this_ptr_conv;
48702         this_ptr_conv.inner = untag_ptr(this_ptr);
48703         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48705         this_ptr_conv.is_owned = false;
48706         LDKCVec_u64Z val_constr;
48707         val_constr.datalen = (*env)->GetArrayLength(env, val);
48708         if (val_constr.datalen > 0)
48709                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
48710         else
48711                 val_constr.data = NULL;
48712         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
48713         for (size_t g = 0; g < val_constr.datalen; g++) {
48714                 int64_t val_conv_6 = val_vals[g];
48715                 val_constr.data[g] = val_conv_6;
48716         }
48717         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
48718         NodeInfo_set_channels(&this_ptr_conv, val_constr);
48719 }
48720
48721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
48722         LDKNodeInfo this_ptr_conv;
48723         this_ptr_conv.inner = untag_ptr(this_ptr);
48724         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48726         this_ptr_conv.is_owned = false;
48727         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
48728         int64_t ret_ref = 0;
48729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48730         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48731         return ret_ref;
48732 }
48733
48734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48735         LDKNodeInfo this_ptr_conv;
48736         this_ptr_conv.inner = untag_ptr(this_ptr);
48737         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48739         this_ptr_conv.is_owned = false;
48740         LDKNodeAnnouncementInfo val_conv;
48741         val_conv.inner = untag_ptr(val);
48742         val_conv.is_owned = ptr_is_owned(val);
48743         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48744         val_conv = NodeAnnouncementInfo_clone(&val_conv);
48745         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
48746 }
48747
48748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv *env, jclass clz, int64_tArray channels_arg, int64_t announcement_info_arg) {
48749         LDKCVec_u64Z channels_arg_constr;
48750         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
48751         if (channels_arg_constr.datalen > 0)
48752                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
48753         else
48754                 channels_arg_constr.data = NULL;
48755         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
48756         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
48757                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
48758                 channels_arg_constr.data[g] = channels_arg_conv_6;
48759         }
48760         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
48761         LDKNodeAnnouncementInfo announcement_info_arg_conv;
48762         announcement_info_arg_conv.inner = untag_ptr(announcement_info_arg);
48763         announcement_info_arg_conv.is_owned = ptr_is_owned(announcement_info_arg);
48764         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
48765         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
48766         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, announcement_info_arg_conv);
48767         int64_t ret_ref = 0;
48768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48769         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48770         return ret_ref;
48771 }
48772
48773 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
48774         LDKNodeInfo ret_var = NodeInfo_clone(arg);
48775         int64_t ret_ref = 0;
48776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48777         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48778         return ret_ref;
48779 }
48780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48781         LDKNodeInfo arg_conv;
48782         arg_conv.inner = untag_ptr(arg);
48783         arg_conv.is_owned = ptr_is_owned(arg);
48784         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48785         arg_conv.is_owned = false;
48786         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
48787         return ret_conv;
48788 }
48789
48790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48791         LDKNodeInfo orig_conv;
48792         orig_conv.inner = untag_ptr(orig);
48793         orig_conv.is_owned = ptr_is_owned(orig);
48794         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48795         orig_conv.is_owned = false;
48796         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
48797         int64_t ret_ref = 0;
48798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48799         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48800         return ret_ref;
48801 }
48802
48803 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48804         LDKNodeInfo a_conv;
48805         a_conv.inner = untag_ptr(a);
48806         a_conv.is_owned = ptr_is_owned(a);
48807         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48808         a_conv.is_owned = false;
48809         LDKNodeInfo b_conv;
48810         b_conv.inner = untag_ptr(b);
48811         b_conv.is_owned = ptr_is_owned(b);
48812         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48813         b_conv.is_owned = false;
48814         jboolean ret_conv = NodeInfo_eq(&a_conv, &b_conv);
48815         return ret_conv;
48816 }
48817
48818 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
48819         LDKNodeInfo obj_conv;
48820         obj_conv.inner = untag_ptr(obj);
48821         obj_conv.is_owned = ptr_is_owned(obj);
48822         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48823         obj_conv.is_owned = false;
48824         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
48825         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48826         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48827         CVec_u8Z_free(ret_var);
48828         return ret_arr;
48829 }
48830
48831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48832         LDKu8slice ser_ref;
48833         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48834         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48835         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
48836         *ret_conv = NodeInfo_read(ser_ref);
48837         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48838         return tag_ptr(ret_conv, true);
48839 }
48840
48841 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
48842         LDKNetworkGraph obj_conv;
48843         obj_conv.inner = untag_ptr(obj);
48844         obj_conv.is_owned = ptr_is_owned(obj);
48845         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48846         obj_conv.is_owned = false;
48847         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
48848         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48849         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48850         CVec_u8Z_free(ret_var);
48851         return ret_arr;
48852 }
48853
48854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
48855         LDKu8slice ser_ref;
48856         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48857         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48858         void* arg_ptr = untag_ptr(arg);
48859         CHECK_ACCESS(arg_ptr);
48860         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
48861         if (arg_conv.free == LDKLogger_JCalls_free) {
48862                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48863                 LDKLogger_JCalls_cloned(&arg_conv);
48864         }
48865         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
48866         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
48867         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48868         return tag_ptr(ret_conv, true);
48869 }
48870
48871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, jclass network, int64_t logger) {
48872         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
48873         void* logger_ptr = untag_ptr(logger);
48874         CHECK_ACCESS(logger_ptr);
48875         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
48876         if (logger_conv.free == LDKLogger_JCalls_free) {
48877                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48878                 LDKLogger_JCalls_cloned(&logger_conv);
48879         }
48880         LDKNetworkGraph ret_var = NetworkGraph_new(network_conv, logger_conv);
48881         int64_t ret_ref = 0;
48882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48883         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48884         return ret_ref;
48885 }
48886
48887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
48888         LDKNetworkGraph this_arg_conv;
48889         this_arg_conv.inner = untag_ptr(this_arg);
48890         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48892         this_arg_conv.is_owned = false;
48893         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
48894         int64_t ret_ref = 0;
48895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48896         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48897         return ret_ref;
48898 }
48899
48900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
48901         LDKNetworkGraph this_arg_conv;
48902         this_arg_conv.inner = untag_ptr(this_arg);
48903         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48905         this_arg_conv.is_owned = false;
48906         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
48907         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
48908         int64_t ret_ref = tag_ptr(ret_copy, true);
48909         return ret_ref;
48910 }
48911
48912 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) {
48913         LDKNetworkGraph this_arg_conv;
48914         this_arg_conv.inner = untag_ptr(this_arg);
48915         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48917         this_arg_conv.is_owned = false;
48918         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
48919 }
48920
48921 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) {
48922         LDKNetworkGraph this_arg_conv;
48923         this_arg_conv.inner = untag_ptr(this_arg);
48924         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48926         this_arg_conv.is_owned = false;
48927         LDKNodeAnnouncement msg_conv;
48928         msg_conv.inner = untag_ptr(msg);
48929         msg_conv.is_owned = ptr_is_owned(msg);
48930         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
48931         msg_conv.is_owned = false;
48932         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
48933         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
48934         return tag_ptr(ret_conv, true);
48935 }
48936
48937 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) {
48938         LDKNetworkGraph this_arg_conv;
48939         this_arg_conv.inner = untag_ptr(this_arg);
48940         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48942         this_arg_conv.is_owned = false;
48943         LDKUnsignedNodeAnnouncement msg_conv;
48944         msg_conv.inner = untag_ptr(msg);
48945         msg_conv.is_owned = ptr_is_owned(msg);
48946         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
48947         msg_conv.is_owned = false;
48948         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
48949         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
48950         return tag_ptr(ret_conv, true);
48951 }
48952
48953 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) {
48954         LDKNetworkGraph this_arg_conv;
48955         this_arg_conv.inner = untag_ptr(this_arg);
48956         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48958         this_arg_conv.is_owned = false;
48959         LDKChannelAnnouncement msg_conv;
48960         msg_conv.inner = untag_ptr(msg);
48961         msg_conv.is_owned = ptr_is_owned(msg);
48962         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
48963         msg_conv.is_owned = false;
48964         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
48965         CHECK_ACCESS(utxo_lookup_ptr);
48966         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
48967         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
48968         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
48969                 // Manually implement clone for Java trait instances
48970                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
48971                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48972                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
48973                 }
48974         }
48975         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
48976         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, utxo_lookup_conv);
48977         return tag_ptr(ret_conv, true);
48978 }
48979
48980 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) {
48981         LDKNetworkGraph this_arg_conv;
48982         this_arg_conv.inner = untag_ptr(this_arg);
48983         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48985         this_arg_conv.is_owned = false;
48986         LDKUnsignedChannelAnnouncement msg_conv;
48987         msg_conv.inner = untag_ptr(msg);
48988         msg_conv.is_owned = ptr_is_owned(msg);
48989         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
48990         msg_conv.is_owned = false;
48991         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
48992         CHECK_ACCESS(utxo_lookup_ptr);
48993         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
48994         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
48995         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
48996                 // Manually implement clone for Java trait instances
48997                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
48998                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48999                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
49000                 }
49001         }
49002         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
49003         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, utxo_lookup_conv);
49004         return tag_ptr(ret_conv, true);
49005 }
49006
49007 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) {
49008         LDKNetworkGraph this_arg_conv;
49009         this_arg_conv.inner = untag_ptr(this_arg);
49010         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49012         this_arg_conv.is_owned = false;
49013         LDKChannelFeatures features_conv;
49014         features_conv.inner = untag_ptr(features);
49015         features_conv.is_owned = ptr_is_owned(features);
49016         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
49017         features_conv = ChannelFeatures_clone(&features_conv);
49018         LDKPublicKey node_id_1_ref;
49019         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
49020         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
49021         LDKPublicKey node_id_2_ref;
49022         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
49023         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
49024         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
49025         *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);
49026         return tag_ptr(ret_conv, true);
49027 }
49028
49029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1channel_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
49030         LDKNetworkGraph this_arg_conv;
49031         this_arg_conv.inner = untag_ptr(this_arg);
49032         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49034         this_arg_conv.is_owned = false;
49035         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
49036 }
49037
49038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1node_1failed_1permanent(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray node_id) {
49039         LDKNetworkGraph this_arg_conv;
49040         this_arg_conv.inner = untag_ptr(this_arg);
49041         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49043         this_arg_conv.is_owned = false;
49044         LDKPublicKey node_id_ref;
49045         CHECK((*env)->GetArrayLength(env, node_id) == 33);
49046         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
49047         NetworkGraph_node_failed_permanent(&this_arg_conv, node_id_ref);
49048 }
49049
49050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels_1and_1tracking(JNIEnv *env, jclass clz, int64_t this_arg) {
49051         LDKNetworkGraph this_arg_conv;
49052         this_arg_conv.inner = untag_ptr(this_arg);
49053         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49055         this_arg_conv.is_owned = false;
49056         NetworkGraph_remove_stale_channels_and_tracking(&this_arg_conv);
49057 }
49058
49059 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) {
49060         LDKNetworkGraph this_arg_conv;
49061         this_arg_conv.inner = untag_ptr(this_arg);
49062         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49064         this_arg_conv.is_owned = false;
49065         NetworkGraph_remove_stale_channels_and_tracking_with_time(&this_arg_conv, current_time_unix);
49066 }
49067
49068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
49069         LDKNetworkGraph this_arg_conv;
49070         this_arg_conv.inner = untag_ptr(this_arg);
49071         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49073         this_arg_conv.is_owned = false;
49074         LDKChannelUpdate msg_conv;
49075         msg_conv.inner = untag_ptr(msg);
49076         msg_conv.is_owned = ptr_is_owned(msg);
49077         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
49078         msg_conv.is_owned = false;
49079         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
49080         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
49081         return tag_ptr(ret_conv, true);
49082 }
49083
49084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
49085         LDKNetworkGraph this_arg_conv;
49086         this_arg_conv.inner = untag_ptr(this_arg);
49087         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49089         this_arg_conv.is_owned = false;
49090         LDKUnsignedChannelUpdate msg_conv;
49091         msg_conv.inner = untag_ptr(msg);
49092         msg_conv.is_owned = ptr_is_owned(msg);
49093         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
49094         msg_conv.is_owned = false;
49095         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
49096         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
49097         return tag_ptr(ret_conv, true);
49098 }
49099
49100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
49101         LDKReadOnlyNetworkGraph this_arg_conv;
49102         this_arg_conv.inner = untag_ptr(this_arg);
49103         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49105         this_arg_conv.is_owned = false;
49106         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
49107         int64_t ret_ref = 0;
49108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49109         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49110         return ret_ref;
49111 }
49112
49113 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
49114         LDKReadOnlyNetworkGraph this_arg_conv;
49115         this_arg_conv.inner = untag_ptr(this_arg);
49116         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49118         this_arg_conv.is_owned = false;
49119         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
49120         int64_tArray ret_arr = NULL;
49121         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49122         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49123         for (size_t g = 0; g < ret_var.datalen; g++) {
49124                 int64_t ret_conv_6_conv = ret_var.data[g];
49125                 ret_arr_ptr[g] = ret_conv_6_conv;
49126         }
49127         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49128         FREE(ret_var.data);
49129         return ret_arr;
49130 }
49131
49132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1node(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
49133         LDKReadOnlyNetworkGraph this_arg_conv;
49134         this_arg_conv.inner = untag_ptr(this_arg);
49135         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49137         this_arg_conv.is_owned = false;
49138         LDKNodeId node_id_conv;
49139         node_id_conv.inner = untag_ptr(node_id);
49140         node_id_conv.is_owned = ptr_is_owned(node_id);
49141         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
49142         node_id_conv.is_owned = false;
49143         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
49144         int64_t ret_ref = 0;
49145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49146         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49147         return ret_ref;
49148 }
49149
49150 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1nodes(JNIEnv *env, jclass clz, int64_t this_arg) {
49151         LDKReadOnlyNetworkGraph this_arg_conv;
49152         this_arg_conv.inner = untag_ptr(this_arg);
49153         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49155         this_arg_conv.is_owned = false;
49156         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
49157         int64_tArray ret_arr = NULL;
49158         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49159         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49160         for (size_t i = 0; i < ret_var.datalen; i++) {
49161                 LDKNodeId ret_conv_8_var = ret_var.data[i];
49162                 int64_t ret_conv_8_ref = 0;
49163                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
49164                 ret_conv_8_ref = tag_ptr(ret_conv_8_var.inner, ret_conv_8_var.is_owned);
49165                 ret_arr_ptr[i] = ret_conv_8_ref;
49166         }
49167         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49168         FREE(ret_var.data);
49169         return ret_arr;
49170 }
49171
49172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
49173         LDKReadOnlyNetworkGraph this_arg_conv;
49174         this_arg_conv.inner = untag_ptr(this_arg);
49175         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49177         this_arg_conv.is_owned = false;
49178         LDKPublicKey pubkey_ref;
49179         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
49180         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
49181         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
49182         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
49183         int64_t ret_ref = tag_ptr(ret_copy, true);
49184         return ret_ref;
49185 }
49186
49187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49188         LDKDefaultRouter this_obj_conv;
49189         this_obj_conv.inner = untag_ptr(this_obj);
49190         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49192         DefaultRouter_free(this_obj_conv);
49193 }
49194
49195 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) {
49196         LDKNetworkGraph network_graph_conv;
49197         network_graph_conv.inner = untag_ptr(network_graph);
49198         network_graph_conv.is_owned = ptr_is_owned(network_graph);
49199         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
49200         network_graph_conv.is_owned = false;
49201         void* logger_ptr = untag_ptr(logger);
49202         CHECK_ACCESS(logger_ptr);
49203         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
49204         if (logger_conv.free == LDKLogger_JCalls_free) {
49205                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49206                 LDKLogger_JCalls_cloned(&logger_conv);
49207         }
49208         LDKThirtyTwoBytes random_seed_bytes_ref;
49209         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
49210         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
49211         void* scorer_ptr = untag_ptr(scorer);
49212         CHECK_ACCESS(scorer_ptr);
49213         LDKLockableScore scorer_conv = *(LDKLockableScore*)(scorer_ptr);
49214         if (scorer_conv.free == LDKLockableScore_JCalls_free) {
49215                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49216                 LDKLockableScore_JCalls_cloned(&scorer_conv);
49217         }
49218         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref, scorer_conv);
49219         int64_t ret_ref = 0;
49220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49221         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49222         return ret_ref;
49223 }
49224
49225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
49226         LDKDefaultRouter this_arg_conv;
49227         this_arg_conv.inner = untag_ptr(this_arg);
49228         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49230         this_arg_conv.is_owned = false;
49231         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
49232         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
49233         return tag_ptr(ret_ret, true);
49234 }
49235
49236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49237         if (!ptr_is_owned(this_ptr)) return;
49238         void* this_ptr_ptr = untag_ptr(this_ptr);
49239         CHECK_ACCESS(this_ptr_ptr);
49240         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
49241         FREE(untag_ptr(this_ptr));
49242         Router_free(this_ptr_conv);
49243 }
49244
49245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49246         LDKScorerAccountingForInFlightHtlcs this_obj_conv;
49247         this_obj_conv.inner = untag_ptr(this_obj);
49248         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49250         ScorerAccountingForInFlightHtlcs_free(this_obj_conv);
49251 }
49252
49253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1new(JNIEnv *env, jclass clz, int64_t scorer, int64_t inflight_htlcs) {
49254         void* scorer_ptr = untag_ptr(scorer);
49255         CHECK_ACCESS(scorer_ptr);
49256         LDKScore scorer_conv = *(LDKScore*)(scorer_ptr);
49257         if (scorer_conv.free == LDKScore_JCalls_free) {
49258                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49259                 LDKScore_JCalls_cloned(&scorer_conv);
49260         }
49261         LDKInFlightHtlcs inflight_htlcs_conv;
49262         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
49263         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
49264         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
49265         inflight_htlcs_conv.is_owned = false;
49266         LDKScorerAccountingForInFlightHtlcs ret_var = ScorerAccountingForInFlightHtlcs_new(scorer_conv, &inflight_htlcs_conv);
49267         int64_t ret_ref = 0;
49268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49269         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49270         return ret_ref;
49271 }
49272
49273 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
49274         LDKScorerAccountingForInFlightHtlcs obj_conv;
49275         obj_conv.inner = untag_ptr(obj);
49276         obj_conv.is_owned = ptr_is_owned(obj);
49277         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49278         obj_conv.is_owned = false;
49279         LDKCVec_u8Z ret_var = ScorerAccountingForInFlightHtlcs_write(&obj_conv);
49280         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49281         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49282         CVec_u8Z_free(ret_var);
49283         return ret_arr;
49284 }
49285
49286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
49287         LDKScorerAccountingForInFlightHtlcs 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         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
49293         *ret_ret = ScorerAccountingForInFlightHtlcs_as_Score(&this_arg_conv);
49294         return tag_ptr(ret_ret, true);
49295 }
49296
49297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49298         LDKInFlightHtlcs this_obj_conv;
49299         this_obj_conv.inner = untag_ptr(this_obj);
49300         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49302         InFlightHtlcs_free(this_obj_conv);
49303 }
49304
49305 static inline uint64_t InFlightHtlcs_clone_ptr(LDKInFlightHtlcs *NONNULL_PTR arg) {
49306         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(arg);
49307         int64_t ret_ref = 0;
49308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49309         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49310         return ret_ref;
49311 }
49312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49313         LDKInFlightHtlcs arg_conv;
49314         arg_conv.inner = untag_ptr(arg);
49315         arg_conv.is_owned = ptr_is_owned(arg);
49316         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49317         arg_conv.is_owned = false;
49318         int64_t ret_conv = InFlightHtlcs_clone_ptr(&arg_conv);
49319         return ret_conv;
49320 }
49321
49322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49323         LDKInFlightHtlcs orig_conv;
49324         orig_conv.inner = untag_ptr(orig);
49325         orig_conv.is_owned = ptr_is_owned(orig);
49326         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49327         orig_conv.is_owned = false;
49328         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(&orig_conv);
49329         int64_t ret_ref = 0;
49330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49331         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49332         return ret_ref;
49333 }
49334
49335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1new(JNIEnv *env, jclass clz) {
49336         LDKInFlightHtlcs ret_var = InFlightHtlcs_new();
49337         int64_t ret_ref = 0;
49338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49339         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49340         return ret_ref;
49341 }
49342
49343 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) {
49344         LDKInFlightHtlcs this_arg_conv;
49345         this_arg_conv.inner = untag_ptr(this_arg);
49346         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49348         this_arg_conv.is_owned = false;
49349         LDKNodeId source_conv;
49350         source_conv.inner = untag_ptr(source);
49351         source_conv.is_owned = ptr_is_owned(source);
49352         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
49353         source_conv.is_owned = false;
49354         LDKNodeId target_conv;
49355         target_conv.inner = untag_ptr(target);
49356         target_conv.is_owned = ptr_is_owned(target);
49357         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
49358         target_conv.is_owned = false;
49359         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
49360         *ret_copy = InFlightHtlcs_used_liquidity_msat(&this_arg_conv, &source_conv, &target_conv, channel_scid);
49361         int64_t ret_ref = tag_ptr(ret_copy, true);
49362         return ret_ref;
49363 }
49364
49365 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
49366         LDKInFlightHtlcs obj_conv;
49367         obj_conv.inner = untag_ptr(obj);
49368         obj_conv.is_owned = ptr_is_owned(obj);
49369         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49370         obj_conv.is_owned = false;
49371         LDKCVec_u8Z ret_var = InFlightHtlcs_write(&obj_conv);
49372         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49373         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49374         CVec_u8Z_free(ret_var);
49375         return ret_arr;
49376 }
49377
49378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49379         LDKu8slice ser_ref;
49380         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49381         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49382         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
49383         *ret_conv = InFlightHtlcs_read(ser_ref);
49384         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49385         return tag_ptr(ret_conv, true);
49386 }
49387
49388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49389         LDKRouteHop this_obj_conv;
49390         this_obj_conv.inner = untag_ptr(this_obj);
49391         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49393         RouteHop_free(this_obj_conv);
49394 }
49395
49396 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
49397         LDKRouteHop this_ptr_conv;
49398         this_ptr_conv.inner = untag_ptr(this_ptr);
49399         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49401         this_ptr_conv.is_owned = false;
49402         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
49403         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
49404         return ret_arr;
49405 }
49406
49407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
49408         LDKRouteHop this_ptr_conv;
49409         this_ptr_conv.inner = untag_ptr(this_ptr);
49410         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49412         this_ptr_conv.is_owned = false;
49413         LDKPublicKey val_ref;
49414         CHECK((*env)->GetArrayLength(env, val) == 33);
49415         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
49416         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
49417 }
49418
49419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
49420         LDKRouteHop this_ptr_conv;
49421         this_ptr_conv.inner = untag_ptr(this_ptr);
49422         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49424         this_ptr_conv.is_owned = false;
49425         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
49426         int64_t ret_ref = 0;
49427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49428         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49429         return ret_ref;
49430 }
49431
49432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49433         LDKRouteHop this_ptr_conv;
49434         this_ptr_conv.inner = untag_ptr(this_ptr);
49435         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49437         this_ptr_conv.is_owned = false;
49438         LDKNodeFeatures val_conv;
49439         val_conv.inner = untag_ptr(val);
49440         val_conv.is_owned = ptr_is_owned(val);
49441         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49442         val_conv = NodeFeatures_clone(&val_conv);
49443         RouteHop_set_node_features(&this_ptr_conv, val_conv);
49444 }
49445
49446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
49447         LDKRouteHop this_ptr_conv;
49448         this_ptr_conv.inner = untag_ptr(this_ptr);
49449         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49451         this_ptr_conv.is_owned = false;
49452         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
49453         return ret_conv;
49454 }
49455
49456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49457         LDKRouteHop this_ptr_conv;
49458         this_ptr_conv.inner = untag_ptr(this_ptr);
49459         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49461         this_ptr_conv.is_owned = false;
49462         RouteHop_set_short_channel_id(&this_ptr_conv, val);
49463 }
49464
49465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
49466         LDKRouteHop this_ptr_conv;
49467         this_ptr_conv.inner = untag_ptr(this_ptr);
49468         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49470         this_ptr_conv.is_owned = false;
49471         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
49472         int64_t ret_ref = 0;
49473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49474         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49475         return ret_ref;
49476 }
49477
49478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49479         LDKRouteHop this_ptr_conv;
49480         this_ptr_conv.inner = untag_ptr(this_ptr);
49481         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49483         this_ptr_conv.is_owned = false;
49484         LDKChannelFeatures val_conv;
49485         val_conv.inner = untag_ptr(val);
49486         val_conv.is_owned = ptr_is_owned(val);
49487         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49488         val_conv = ChannelFeatures_clone(&val_conv);
49489         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
49490 }
49491
49492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49493         LDKRouteHop this_ptr_conv;
49494         this_ptr_conv.inner = untag_ptr(this_ptr);
49495         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49497         this_ptr_conv.is_owned = false;
49498         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
49499         return ret_conv;
49500 }
49501
49502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49503         LDKRouteHop this_ptr_conv;
49504         this_ptr_conv.inner = untag_ptr(this_ptr);
49505         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49507         this_ptr_conv.is_owned = false;
49508         RouteHop_set_fee_msat(&this_ptr_conv, val);
49509 }
49510
49511 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
49512         LDKRouteHop this_ptr_conv;
49513         this_ptr_conv.inner = untag_ptr(this_ptr);
49514         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49516         this_ptr_conv.is_owned = false;
49517         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
49518         return ret_conv;
49519 }
49520
49521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
49522         LDKRouteHop 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         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
49528 }
49529
49530 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) {
49531         LDKPublicKey pubkey_arg_ref;
49532         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
49533         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
49534         LDKNodeFeatures node_features_arg_conv;
49535         node_features_arg_conv.inner = untag_ptr(node_features_arg);
49536         node_features_arg_conv.is_owned = ptr_is_owned(node_features_arg);
49537         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
49538         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
49539         LDKChannelFeatures channel_features_arg_conv;
49540         channel_features_arg_conv.inner = untag_ptr(channel_features_arg);
49541         channel_features_arg_conv.is_owned = ptr_is_owned(channel_features_arg);
49542         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
49543         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
49544         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);
49545         int64_t ret_ref = 0;
49546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49547         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49548         return ret_ref;
49549 }
49550
49551 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
49552         LDKRouteHop ret_var = RouteHop_clone(arg);
49553         int64_t ret_ref = 0;
49554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49555         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49556         return ret_ref;
49557 }
49558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49559         LDKRouteHop arg_conv;
49560         arg_conv.inner = untag_ptr(arg);
49561         arg_conv.is_owned = ptr_is_owned(arg);
49562         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49563         arg_conv.is_owned = false;
49564         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
49565         return ret_conv;
49566 }
49567
49568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49569         LDKRouteHop orig_conv;
49570         orig_conv.inner = untag_ptr(orig);
49571         orig_conv.is_owned = ptr_is_owned(orig);
49572         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49573         orig_conv.is_owned = false;
49574         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
49575         int64_t ret_ref = 0;
49576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49577         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49578         return ret_ref;
49579 }
49580
49581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
49582         LDKRouteHop o_conv;
49583         o_conv.inner = untag_ptr(o);
49584         o_conv.is_owned = ptr_is_owned(o);
49585         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49586         o_conv.is_owned = false;
49587         int64_t ret_conv = RouteHop_hash(&o_conv);
49588         return ret_conv;
49589 }
49590
49591 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49592         LDKRouteHop a_conv;
49593         a_conv.inner = untag_ptr(a);
49594         a_conv.is_owned = ptr_is_owned(a);
49595         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49596         a_conv.is_owned = false;
49597         LDKRouteHop b_conv;
49598         b_conv.inner = untag_ptr(b);
49599         b_conv.is_owned = ptr_is_owned(b);
49600         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49601         b_conv.is_owned = false;
49602         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
49603         return ret_conv;
49604 }
49605
49606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
49607         LDKRouteHop obj_conv;
49608         obj_conv.inner = untag_ptr(obj);
49609         obj_conv.is_owned = ptr_is_owned(obj);
49610         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49611         obj_conv.is_owned = false;
49612         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
49613         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49614         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49615         CVec_u8Z_free(ret_var);
49616         return ret_arr;
49617 }
49618
49619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49620         LDKu8slice ser_ref;
49621         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49622         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49623         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
49624         *ret_conv = RouteHop_read(ser_ref);
49625         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49626         return tag_ptr(ret_conv, true);
49627 }
49628
49629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49630         LDKRoute this_obj_conv;
49631         this_obj_conv.inner = untag_ptr(this_obj);
49632         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49634         Route_free(this_obj_conv);
49635 }
49636
49637 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
49638         LDKRoute this_ptr_conv;
49639         this_ptr_conv.inner = untag_ptr(this_ptr);
49640         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49642         this_ptr_conv.is_owned = false;
49643         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
49644         jobjectArray ret_arr = NULL;
49645         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
49646         ;
49647         for (size_t m = 0; m < ret_var.datalen; m++) {
49648                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
49649                 int64_tArray ret_conv_12_arr = NULL;
49650                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
49651                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
49652                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
49653                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
49654                         int64_t ret_conv_12_conv_10_ref = 0;
49655                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
49656                         ret_conv_12_conv_10_ref = tag_ptr(ret_conv_12_conv_10_var.inner, ret_conv_12_conv_10_var.is_owned);
49657                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
49658                 }
49659                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
49660                 FREE(ret_conv_12_var.data);
49661                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
49662         }
49663         
49664         FREE(ret_var.data);
49665         return ret_arr;
49666 }
49667
49668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
49669         LDKRoute this_ptr_conv;
49670         this_ptr_conv.inner = untag_ptr(this_ptr);
49671         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49673         this_ptr_conv.is_owned = false;
49674         LDKCVec_CVec_RouteHopZZ val_constr;
49675         val_constr.datalen = (*env)->GetArrayLength(env, val);
49676         if (val_constr.datalen > 0)
49677                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
49678         else
49679                 val_constr.data = NULL;
49680         for (size_t m = 0; m < val_constr.datalen; m++) {
49681                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
49682                 LDKCVec_RouteHopZ val_conv_12_constr;
49683                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
49684                 if (val_conv_12_constr.datalen > 0)
49685                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
49686                 else
49687                         val_conv_12_constr.data = NULL;
49688                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
49689                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
49690                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
49691                         LDKRouteHop val_conv_12_conv_10_conv;
49692                         val_conv_12_conv_10_conv.inner = untag_ptr(val_conv_12_conv_10);
49693                         val_conv_12_conv_10_conv.is_owned = ptr_is_owned(val_conv_12_conv_10);
49694                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
49695                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
49696                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
49697                 }
49698                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
49699                 val_constr.data[m] = val_conv_12_constr;
49700         }
49701         Route_set_paths(&this_ptr_conv, val_constr);
49702 }
49703
49704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
49705         LDKRoute this_ptr_conv;
49706         this_ptr_conv.inner = untag_ptr(this_ptr);
49707         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49709         this_ptr_conv.is_owned = false;
49710         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
49711         int64_t ret_ref = 0;
49712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49713         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49714         return ret_ref;
49715 }
49716
49717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49718         LDKRoute this_ptr_conv;
49719         this_ptr_conv.inner = untag_ptr(this_ptr);
49720         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49722         this_ptr_conv.is_owned = false;
49723         LDKPaymentParameters val_conv;
49724         val_conv.inner = untag_ptr(val);
49725         val_conv.is_owned = ptr_is_owned(val);
49726         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49727         val_conv = PaymentParameters_clone(&val_conv);
49728         Route_set_payment_params(&this_ptr_conv, val_conv);
49729 }
49730
49731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
49732         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
49733         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
49734         if (paths_arg_constr.datalen > 0)
49735                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
49736         else
49737                 paths_arg_constr.data = NULL;
49738         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
49739                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
49740                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
49741                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
49742                 if (paths_arg_conv_12_constr.datalen > 0)
49743                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
49744                 else
49745                         paths_arg_conv_12_constr.data = NULL;
49746                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
49747                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
49748                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
49749                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
49750                         paths_arg_conv_12_conv_10_conv.inner = untag_ptr(paths_arg_conv_12_conv_10);
49751                         paths_arg_conv_12_conv_10_conv.is_owned = ptr_is_owned(paths_arg_conv_12_conv_10);
49752                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
49753                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
49754                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
49755                 }
49756                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
49757                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
49758         }
49759         LDKPaymentParameters payment_params_arg_conv;
49760         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
49761         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
49762         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
49763         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
49764         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
49765         int64_t ret_ref = 0;
49766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49767         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49768         return ret_ref;
49769 }
49770
49771 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
49772         LDKRoute ret_var = Route_clone(arg);
49773         int64_t ret_ref = 0;
49774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49775         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49776         return ret_ref;
49777 }
49778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49779         LDKRoute arg_conv;
49780         arg_conv.inner = untag_ptr(arg);
49781         arg_conv.is_owned = ptr_is_owned(arg);
49782         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49783         arg_conv.is_owned = false;
49784         int64_t ret_conv = Route_clone_ptr(&arg_conv);
49785         return ret_conv;
49786 }
49787
49788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49789         LDKRoute orig_conv;
49790         orig_conv.inner = untag_ptr(orig);
49791         orig_conv.is_owned = ptr_is_owned(orig);
49792         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49793         orig_conv.is_owned = false;
49794         LDKRoute ret_var = Route_clone(&orig_conv);
49795         int64_t ret_ref = 0;
49796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49798         return ret_ref;
49799 }
49800
49801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
49802         LDKRoute o_conv;
49803         o_conv.inner = untag_ptr(o);
49804         o_conv.is_owned = ptr_is_owned(o);
49805         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49806         o_conv.is_owned = false;
49807         int64_t ret_conv = Route_hash(&o_conv);
49808         return ret_conv;
49809 }
49810
49811 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49812         LDKRoute a_conv;
49813         a_conv.inner = untag_ptr(a);
49814         a_conv.is_owned = ptr_is_owned(a);
49815         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49816         a_conv.is_owned = false;
49817         LDKRoute b_conv;
49818         b_conv.inner = untag_ptr(b);
49819         b_conv.is_owned = ptr_is_owned(b);
49820         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49821         b_conv.is_owned = false;
49822         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
49823         return ret_conv;
49824 }
49825
49826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
49827         LDKRoute this_arg_conv;
49828         this_arg_conv.inner = untag_ptr(this_arg);
49829         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49831         this_arg_conv.is_owned = false;
49832         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
49833         return ret_conv;
49834 }
49835
49836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
49837         LDKRoute this_arg_conv;
49838         this_arg_conv.inner = untag_ptr(this_arg);
49839         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49841         this_arg_conv.is_owned = false;
49842         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
49843         return ret_conv;
49844 }
49845
49846 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
49847         LDKRoute obj_conv;
49848         obj_conv.inner = untag_ptr(obj);
49849         obj_conv.is_owned = ptr_is_owned(obj);
49850         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49851         obj_conv.is_owned = false;
49852         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
49853         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49854         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49855         CVec_u8Z_free(ret_var);
49856         return ret_arr;
49857 }
49858
49859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49860         LDKu8slice ser_ref;
49861         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49862         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49863         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
49864         *ret_conv = Route_read(ser_ref);
49865         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49866         return tag_ptr(ret_conv, true);
49867 }
49868
49869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49870         LDKRouteParameters this_obj_conv;
49871         this_obj_conv.inner = untag_ptr(this_obj);
49872         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49874         RouteParameters_free(this_obj_conv);
49875 }
49876
49877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
49878         LDKRouteParameters this_ptr_conv;
49879         this_ptr_conv.inner = untag_ptr(this_ptr);
49880         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49882         this_ptr_conv.is_owned = false;
49883         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
49884         int64_t ret_ref = 0;
49885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49886         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49887         return ret_ref;
49888 }
49889
49890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49891         LDKRouteParameters this_ptr_conv;
49892         this_ptr_conv.inner = untag_ptr(this_ptr);
49893         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49895         this_ptr_conv.is_owned = false;
49896         LDKPaymentParameters val_conv;
49897         val_conv.inner = untag_ptr(val);
49898         val_conv.is_owned = ptr_is_owned(val);
49899         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49900         val_conv = PaymentParameters_clone(&val_conv);
49901         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
49902 }
49903
49904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49905         LDKRouteParameters 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         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
49911         return ret_conv;
49912 }
49913
49914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49915         LDKRouteParameters this_ptr_conv;
49916         this_ptr_conv.inner = untag_ptr(this_ptr);
49917         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49919         this_ptr_conv.is_owned = false;
49920         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
49921 }
49922
49923 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) {
49924         LDKPaymentParameters payment_params_arg_conv;
49925         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
49926         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
49927         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
49928         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
49929         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg);
49930         int64_t ret_ref = 0;
49931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49932         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49933         return ret_ref;
49934 }
49935
49936 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
49937         LDKRouteParameters ret_var = RouteParameters_clone(arg);
49938         int64_t ret_ref = 0;
49939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49940         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49941         return ret_ref;
49942 }
49943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49944         LDKRouteParameters arg_conv;
49945         arg_conv.inner = untag_ptr(arg);
49946         arg_conv.is_owned = ptr_is_owned(arg);
49947         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49948         arg_conv.is_owned = false;
49949         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
49950         return ret_conv;
49951 }
49952
49953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49954         LDKRouteParameters orig_conv;
49955         orig_conv.inner = untag_ptr(orig);
49956         orig_conv.is_owned = ptr_is_owned(orig);
49957         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49958         orig_conv.is_owned = false;
49959         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
49960         int64_t ret_ref = 0;
49961         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49962         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49963         return ret_ref;
49964 }
49965
49966 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49967         LDKRouteParameters a_conv;
49968         a_conv.inner = untag_ptr(a);
49969         a_conv.is_owned = ptr_is_owned(a);
49970         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49971         a_conv.is_owned = false;
49972         LDKRouteParameters b_conv;
49973         b_conv.inner = untag_ptr(b);
49974         b_conv.is_owned = ptr_is_owned(b);
49975         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49976         b_conv.is_owned = false;
49977         jboolean ret_conv = RouteParameters_eq(&a_conv, &b_conv);
49978         return ret_conv;
49979 }
49980
49981 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
49982         LDKRouteParameters obj_conv;
49983         obj_conv.inner = untag_ptr(obj);
49984         obj_conv.is_owned = ptr_is_owned(obj);
49985         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49986         obj_conv.is_owned = false;
49987         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
49988         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49989         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49990         CVec_u8Z_free(ret_var);
49991         return ret_arr;
49992 }
49993
49994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49995         LDKu8slice ser_ref;
49996         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49997         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49998         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
49999         *ret_conv = RouteParameters_read(ser_ref);
50000         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50001         return tag_ptr(ret_conv, true);
50002 }
50003
50004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50005         LDKPaymentParameters this_obj_conv;
50006         this_obj_conv.inner = untag_ptr(this_obj);
50007         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50009         PaymentParameters_free(this_obj_conv);
50010 }
50011
50012 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
50013         LDKPaymentParameters this_ptr_conv;
50014         this_ptr_conv.inner = untag_ptr(this_ptr);
50015         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50017         this_ptr_conv.is_owned = false;
50018         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50019         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
50020         return ret_arr;
50021 }
50022
50023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
50024         LDKPaymentParameters this_ptr_conv;
50025         this_ptr_conv.inner = untag_ptr(this_ptr);
50026         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50028         this_ptr_conv.is_owned = false;
50029         LDKPublicKey val_ref;
50030         CHECK((*env)->GetArrayLength(env, val) == 33);
50031         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
50032         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
50033 }
50034
50035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
50036         LDKPaymentParameters this_ptr_conv;
50037         this_ptr_conv.inner = untag_ptr(this_ptr);
50038         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50040         this_ptr_conv.is_owned = false;
50041         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
50042         int64_t ret_ref = 0;
50043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50044         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50045         return ret_ref;
50046 }
50047
50048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50049         LDKPaymentParameters this_ptr_conv;
50050         this_ptr_conv.inner = untag_ptr(this_ptr);
50051         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50053         this_ptr_conv.is_owned = false;
50054         LDKInvoiceFeatures val_conv;
50055         val_conv.inner = untag_ptr(val);
50056         val_conv.is_owned = ptr_is_owned(val);
50057         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
50058         val_conv = InvoiceFeatures_clone(&val_conv);
50059         PaymentParameters_set_features(&this_ptr_conv, val_conv);
50060 }
50061
50062 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
50063         LDKPaymentParameters this_ptr_conv;
50064         this_ptr_conv.inner = untag_ptr(this_ptr);
50065         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50067         this_ptr_conv.is_owned = false;
50068         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
50069         int64_tArray ret_arr = NULL;
50070         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50071         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50072         for (size_t l = 0; l < ret_var.datalen; l++) {
50073                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
50074                 int64_t ret_conv_11_ref = 0;
50075                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
50076                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
50077                 ret_arr_ptr[l] = ret_conv_11_ref;
50078         }
50079         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50080         FREE(ret_var.data);
50081         return ret_arr;
50082 }
50083
50084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
50085         LDKPaymentParameters this_ptr_conv;
50086         this_ptr_conv.inner = untag_ptr(this_ptr);
50087         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50089         this_ptr_conv.is_owned = false;
50090         LDKCVec_RouteHintZ val_constr;
50091         val_constr.datalen = (*env)->GetArrayLength(env, val);
50092         if (val_constr.datalen > 0)
50093                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
50094         else
50095                 val_constr.data = NULL;
50096         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
50097         for (size_t l = 0; l < val_constr.datalen; l++) {
50098                 int64_t val_conv_11 = val_vals[l];
50099                 LDKRouteHint val_conv_11_conv;
50100                 val_conv_11_conv.inner = untag_ptr(val_conv_11);
50101                 val_conv_11_conv.is_owned = ptr_is_owned(val_conv_11);
50102                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
50103                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
50104                 val_constr.data[l] = val_conv_11_conv;
50105         }
50106         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
50107         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
50108 }
50109
50110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
50111         LDKPaymentParameters this_ptr_conv;
50112         this_ptr_conv.inner = untag_ptr(this_ptr);
50113         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50115         this_ptr_conv.is_owned = false;
50116         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
50117         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
50118         int64_t ret_ref = tag_ptr(ret_copy, true);
50119         return ret_ref;
50120 }
50121
50122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50123         LDKPaymentParameters this_ptr_conv;
50124         this_ptr_conv.inner = untag_ptr(this_ptr);
50125         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50127         this_ptr_conv.is_owned = false;
50128         void* val_ptr = untag_ptr(val);
50129         CHECK_ACCESS(val_ptr);
50130         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
50131         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
50132         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
50133 }
50134
50135 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
50136         LDKPaymentParameters this_ptr_conv;
50137         this_ptr_conv.inner = untag_ptr(this_ptr);
50138         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50140         this_ptr_conv.is_owned = false;
50141         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
50142         return ret_conv;
50143 }
50144
50145 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) {
50146         LDKPaymentParameters this_ptr_conv;
50147         this_ptr_conv.inner = untag_ptr(this_ptr);
50148         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50150         this_ptr_conv.is_owned = false;
50151         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
50152 }
50153
50154 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
50155         LDKPaymentParameters this_ptr_conv;
50156         this_ptr_conv.inner = untag_ptr(this_ptr);
50157         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50159         this_ptr_conv.is_owned = false;
50160         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
50161         return ret_conv;
50162 }
50163
50164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
50165         LDKPaymentParameters this_ptr_conv;
50166         this_ptr_conv.inner = untag_ptr(this_ptr);
50167         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50169         this_ptr_conv.is_owned = false;
50170         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
50171 }
50172
50173 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) {
50174         LDKPaymentParameters this_ptr_conv;
50175         this_ptr_conv.inner = untag_ptr(this_ptr);
50176         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50178         this_ptr_conv.is_owned = false;
50179         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
50180         return ret_conv;
50181 }
50182
50183 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) {
50184         LDKPaymentParameters this_ptr_conv;
50185         this_ptr_conv.inner = untag_ptr(this_ptr);
50186         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50188         this_ptr_conv.is_owned = false;
50189         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
50190 }
50191
50192 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
50193         LDKPaymentParameters this_ptr_conv;
50194         this_ptr_conv.inner = untag_ptr(this_ptr);
50195         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50197         this_ptr_conv.is_owned = false;
50198         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
50199         int64_tArray ret_arr = NULL;
50200         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50201         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50202         for (size_t g = 0; g < ret_var.datalen; g++) {
50203                 int64_t ret_conv_6_conv = ret_var.data[g];
50204                 ret_arr_ptr[g] = ret_conv_6_conv;
50205         }
50206         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50207         FREE(ret_var.data);
50208         return ret_arr;
50209 }
50210
50211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
50212         LDKPaymentParameters this_ptr_conv;
50213         this_ptr_conv.inner = untag_ptr(this_ptr);
50214         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50216         this_ptr_conv.is_owned = false;
50217         LDKCVec_u64Z val_constr;
50218         val_constr.datalen = (*env)->GetArrayLength(env, val);
50219         if (val_constr.datalen > 0)
50220                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
50221         else
50222                 val_constr.data = NULL;
50223         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
50224         for (size_t g = 0; g < val_constr.datalen; g++) {
50225                 int64_t val_conv_6 = val_vals[g];
50226                 val_constr.data[g] = val_conv_6;
50227         }
50228         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
50229         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
50230 }
50231
50232 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
50233         LDKPaymentParameters this_ptr_conv;
50234         this_ptr_conv.inner = untag_ptr(this_ptr);
50235         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50237         this_ptr_conv.is_owned = false;
50238         int32_t ret_conv = PaymentParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
50239         return ret_conv;
50240 }
50241
50242 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) {
50243         LDKPaymentParameters this_ptr_conv;
50244         this_ptr_conv.inner = untag_ptr(this_ptr);
50245         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50247         this_ptr_conv.is_owned = false;
50248         PaymentParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
50249 }
50250
50251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1new(JNIEnv *env, jclass clz, int8_tArray payee_pubkey_arg, int64_t features_arg, int64_tArray route_hints_arg, int64_t expiry_time_arg, int32_t max_total_cltv_expiry_delta_arg, int8_t max_path_count_arg, int8_t max_channel_saturation_power_of_half_arg, int64_tArray previously_failed_channels_arg, int32_t final_cltv_expiry_delta_arg) {
50252         LDKPublicKey payee_pubkey_arg_ref;
50253         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
50254         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
50255         LDKInvoiceFeatures features_arg_conv;
50256         features_arg_conv.inner = untag_ptr(features_arg);
50257         features_arg_conv.is_owned = ptr_is_owned(features_arg);
50258         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
50259         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
50260         LDKCVec_RouteHintZ route_hints_arg_constr;
50261         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
50262         if (route_hints_arg_constr.datalen > 0)
50263                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
50264         else
50265                 route_hints_arg_constr.data = NULL;
50266         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
50267         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
50268                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
50269                 LDKRouteHint route_hints_arg_conv_11_conv;
50270                 route_hints_arg_conv_11_conv.inner = untag_ptr(route_hints_arg_conv_11);
50271                 route_hints_arg_conv_11_conv.is_owned = ptr_is_owned(route_hints_arg_conv_11);
50272                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
50273                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
50274                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
50275         }
50276         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
50277         void* expiry_time_arg_ptr = untag_ptr(expiry_time_arg);
50278         CHECK_ACCESS(expiry_time_arg_ptr);
50279         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
50280         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(expiry_time_arg));
50281         LDKCVec_u64Z previously_failed_channels_arg_constr;
50282         previously_failed_channels_arg_constr.datalen = (*env)->GetArrayLength(env, previously_failed_channels_arg);
50283         if (previously_failed_channels_arg_constr.datalen > 0)
50284                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
50285         else
50286                 previously_failed_channels_arg_constr.data = NULL;
50287         int64_t* previously_failed_channels_arg_vals = (*env)->GetLongArrayElements (env, previously_failed_channels_arg, NULL);
50288         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
50289                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
50290                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
50291         }
50292         (*env)->ReleaseLongArrayElements(env, previously_failed_channels_arg, previously_failed_channels_arg_vals, 0);
50293         LDKPaymentParameters ret_var = PaymentParameters_new(payee_pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv, max_total_cltv_expiry_delta_arg, max_path_count_arg, max_channel_saturation_power_of_half_arg, previously_failed_channels_arg_constr, final_cltv_expiry_delta_arg);
50294         int64_t ret_ref = 0;
50295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50296         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50297         return ret_ref;
50298 }
50299
50300 static inline uint64_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
50301         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
50302         int64_t ret_ref = 0;
50303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50304         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50305         return ret_ref;
50306 }
50307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50308         LDKPaymentParameters arg_conv;
50309         arg_conv.inner = untag_ptr(arg);
50310         arg_conv.is_owned = ptr_is_owned(arg);
50311         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50312         arg_conv.is_owned = false;
50313         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
50314         return ret_conv;
50315 }
50316
50317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50318         LDKPaymentParameters orig_conv;
50319         orig_conv.inner = untag_ptr(orig);
50320         orig_conv.is_owned = ptr_is_owned(orig);
50321         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50322         orig_conv.is_owned = false;
50323         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
50324         int64_t ret_ref = 0;
50325         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50326         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50327         return ret_ref;
50328 }
50329
50330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
50331         LDKPaymentParameters o_conv;
50332         o_conv.inner = untag_ptr(o);
50333         o_conv.is_owned = ptr_is_owned(o);
50334         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50335         o_conv.is_owned = false;
50336         int64_t ret_conv = PaymentParameters_hash(&o_conv);
50337         return ret_conv;
50338 }
50339
50340 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50341         LDKPaymentParameters a_conv;
50342         a_conv.inner = untag_ptr(a);
50343         a_conv.is_owned = ptr_is_owned(a);
50344         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50345         a_conv.is_owned = false;
50346         LDKPaymentParameters b_conv;
50347         b_conv.inner = untag_ptr(b);
50348         b_conv.is_owned = ptr_is_owned(b);
50349         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50350         b_conv.is_owned = false;
50351         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
50352         return ret_conv;
50353 }
50354
50355 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
50356         LDKPaymentParameters obj_conv;
50357         obj_conv.inner = untag_ptr(obj);
50358         obj_conv.is_owned = ptr_is_owned(obj);
50359         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50360         obj_conv.is_owned = false;
50361         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
50362         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50363         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50364         CVec_u8Z_free(ret_var);
50365         return ret_arr;
50366 }
50367
50368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser, int32_t arg) {
50369         LDKu8slice ser_ref;
50370         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50371         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50372         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
50373         *ret_conv = PaymentParameters_read(ser_ref, arg);
50374         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50375         return tag_ptr(ret_conv, true);
50376 }
50377
50378 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) {
50379         LDKPublicKey payee_pubkey_ref;
50380         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
50381         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
50382         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref, final_cltv_expiry_delta);
50383         int64_t ret_ref = 0;
50384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50385         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50386         return ret_ref;
50387 }
50388
50389 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) {
50390         LDKPublicKey payee_pubkey_ref;
50391         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
50392         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
50393         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref, final_cltv_expiry_delta);
50394         int64_t ret_ref = 0;
50395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50396         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50397         return ret_ref;
50398 }
50399
50400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50401         LDKRouteHint this_obj_conv;
50402         this_obj_conv.inner = untag_ptr(this_obj);
50403         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50405         RouteHint_free(this_obj_conv);
50406 }
50407
50408 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
50409         LDKRouteHint this_ptr_conv;
50410         this_ptr_conv.inner = untag_ptr(this_ptr);
50411         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50413         this_ptr_conv.is_owned = false;
50414         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
50415         int64_tArray ret_arr = NULL;
50416         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50417         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50418         for (size_t o = 0; o < ret_var.datalen; o++) {
50419                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
50420                 int64_t ret_conv_14_ref = 0;
50421                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
50422                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
50423                 ret_arr_ptr[o] = ret_conv_14_ref;
50424         }
50425         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50426         FREE(ret_var.data);
50427         return ret_arr;
50428 }
50429
50430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
50431         LDKRouteHint this_ptr_conv;
50432         this_ptr_conv.inner = untag_ptr(this_ptr);
50433         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50435         this_ptr_conv.is_owned = false;
50436         LDKCVec_RouteHintHopZ val_constr;
50437         val_constr.datalen = (*env)->GetArrayLength(env, val);
50438         if (val_constr.datalen > 0)
50439                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
50440         else
50441                 val_constr.data = NULL;
50442         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
50443         for (size_t o = 0; o < val_constr.datalen; o++) {
50444                 int64_t val_conv_14 = val_vals[o];
50445                 LDKRouteHintHop val_conv_14_conv;
50446                 val_conv_14_conv.inner = untag_ptr(val_conv_14);
50447                 val_conv_14_conv.is_owned = ptr_is_owned(val_conv_14);
50448                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
50449                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
50450                 val_constr.data[o] = val_conv_14_conv;
50451         }
50452         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
50453         RouteHint_set_a(&this_ptr_conv, val_constr);
50454 }
50455
50456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
50457         LDKCVec_RouteHintHopZ a_arg_constr;
50458         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
50459         if (a_arg_constr.datalen > 0)
50460                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
50461         else
50462                 a_arg_constr.data = NULL;
50463         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
50464         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
50465                 int64_t a_arg_conv_14 = a_arg_vals[o];
50466                 LDKRouteHintHop a_arg_conv_14_conv;
50467                 a_arg_conv_14_conv.inner = untag_ptr(a_arg_conv_14);
50468                 a_arg_conv_14_conv.is_owned = ptr_is_owned(a_arg_conv_14);
50469                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
50470                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
50471                 a_arg_constr.data[o] = a_arg_conv_14_conv;
50472         }
50473         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
50474         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
50475         int64_t ret_ref = 0;
50476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50477         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50478         return ret_ref;
50479 }
50480
50481 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
50482         LDKRouteHint ret_var = RouteHint_clone(arg);
50483         int64_t ret_ref = 0;
50484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50485         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50486         return ret_ref;
50487 }
50488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50489         LDKRouteHint arg_conv;
50490         arg_conv.inner = untag_ptr(arg);
50491         arg_conv.is_owned = ptr_is_owned(arg);
50492         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50493         arg_conv.is_owned = false;
50494         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
50495         return ret_conv;
50496 }
50497
50498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50499         LDKRouteHint orig_conv;
50500         orig_conv.inner = untag_ptr(orig);
50501         orig_conv.is_owned = ptr_is_owned(orig);
50502         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50503         orig_conv.is_owned = false;
50504         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
50505         int64_t ret_ref = 0;
50506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50507         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50508         return ret_ref;
50509 }
50510
50511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
50512         LDKRouteHint o_conv;
50513         o_conv.inner = untag_ptr(o);
50514         o_conv.is_owned = ptr_is_owned(o);
50515         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50516         o_conv.is_owned = false;
50517         int64_t ret_conv = RouteHint_hash(&o_conv);
50518         return ret_conv;
50519 }
50520
50521 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50522         LDKRouteHint a_conv;
50523         a_conv.inner = untag_ptr(a);
50524         a_conv.is_owned = ptr_is_owned(a);
50525         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50526         a_conv.is_owned = false;
50527         LDKRouteHint b_conv;
50528         b_conv.inner = untag_ptr(b);
50529         b_conv.is_owned = ptr_is_owned(b);
50530         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50531         b_conv.is_owned = false;
50532         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
50533         return ret_conv;
50534 }
50535
50536 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
50537         LDKRouteHint obj_conv;
50538         obj_conv.inner = untag_ptr(obj);
50539         obj_conv.is_owned = ptr_is_owned(obj);
50540         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50541         obj_conv.is_owned = false;
50542         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
50543         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50544         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50545         CVec_u8Z_free(ret_var);
50546         return ret_arr;
50547 }
50548
50549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50550         LDKu8slice ser_ref;
50551         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50552         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50553         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
50554         *ret_conv = RouteHint_read(ser_ref);
50555         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50556         return tag_ptr(ret_conv, true);
50557 }
50558
50559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50560         LDKRouteHintHop this_obj_conv;
50561         this_obj_conv.inner = untag_ptr(this_obj);
50562         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50564         RouteHintHop_free(this_obj_conv);
50565 }
50566
50567 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
50568         LDKRouteHintHop this_ptr_conv;
50569         this_ptr_conv.inner = untag_ptr(this_ptr);
50570         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50572         this_ptr_conv.is_owned = false;
50573         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50574         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
50575         return ret_arr;
50576 }
50577
50578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
50579         LDKRouteHintHop this_ptr_conv;
50580         this_ptr_conv.inner = untag_ptr(this_ptr);
50581         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50583         this_ptr_conv.is_owned = false;
50584         LDKPublicKey val_ref;
50585         CHECK((*env)->GetArrayLength(env, val) == 33);
50586         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
50587         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
50588 }
50589
50590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
50591         LDKRouteHintHop this_ptr_conv;
50592         this_ptr_conv.inner = untag_ptr(this_ptr);
50593         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50595         this_ptr_conv.is_owned = false;
50596         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
50597         return ret_conv;
50598 }
50599
50600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50601         LDKRouteHintHop this_ptr_conv;
50602         this_ptr_conv.inner = untag_ptr(this_ptr);
50603         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50605         this_ptr_conv.is_owned = false;
50606         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
50607 }
50608
50609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
50610         LDKRouteHintHop this_ptr_conv;
50611         this_ptr_conv.inner = untag_ptr(this_ptr);
50612         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50614         this_ptr_conv.is_owned = false;
50615         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
50616         int64_t ret_ref = 0;
50617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50618         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50619         return ret_ref;
50620 }
50621
50622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50623         LDKRouteHintHop this_ptr_conv;
50624         this_ptr_conv.inner = untag_ptr(this_ptr);
50625         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50627         this_ptr_conv.is_owned = false;
50628         LDKRoutingFees val_conv;
50629         val_conv.inner = untag_ptr(val);
50630         val_conv.is_owned = ptr_is_owned(val);
50631         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
50632         val_conv = RoutingFees_clone(&val_conv);
50633         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
50634 }
50635
50636 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
50637         LDKRouteHintHop this_ptr_conv;
50638         this_ptr_conv.inner = untag_ptr(this_ptr);
50639         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50641         this_ptr_conv.is_owned = false;
50642         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
50643         return ret_conv;
50644 }
50645
50646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
50647         LDKRouteHintHop 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         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
50653 }
50654
50655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
50656         LDKRouteHintHop this_ptr_conv;
50657         this_ptr_conv.inner = untag_ptr(this_ptr);
50658         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50660         this_ptr_conv.is_owned = false;
50661         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
50662         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
50663         int64_t ret_ref = tag_ptr(ret_copy, true);
50664         return ret_ref;
50665 }
50666
50667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50668         LDKRouteHintHop this_ptr_conv;
50669         this_ptr_conv.inner = untag_ptr(this_ptr);
50670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50672         this_ptr_conv.is_owned = false;
50673         void* val_ptr = untag_ptr(val);
50674         CHECK_ACCESS(val_ptr);
50675         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
50676         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
50677         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
50678 }
50679
50680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
50681         LDKRouteHintHop this_ptr_conv;
50682         this_ptr_conv.inner = untag_ptr(this_ptr);
50683         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50685         this_ptr_conv.is_owned = false;
50686         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
50687         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
50688         int64_t ret_ref = tag_ptr(ret_copy, true);
50689         return ret_ref;
50690 }
50691
50692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50693         LDKRouteHintHop 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         void* val_ptr = untag_ptr(val);
50699         CHECK_ACCESS(val_ptr);
50700         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
50701         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
50702         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
50703 }
50704
50705 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) {
50706         LDKPublicKey src_node_id_arg_ref;
50707         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
50708         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
50709         LDKRoutingFees fees_arg_conv;
50710         fees_arg_conv.inner = untag_ptr(fees_arg);
50711         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
50712         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
50713         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
50714         void* htlc_minimum_msat_arg_ptr = untag_ptr(htlc_minimum_msat_arg);
50715         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
50716         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
50717         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_minimum_msat_arg));
50718         void* htlc_maximum_msat_arg_ptr = untag_ptr(htlc_maximum_msat_arg);
50719         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
50720         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
50721         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat_arg));
50722         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);
50723         int64_t ret_ref = 0;
50724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50725         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50726         return ret_ref;
50727 }
50728
50729 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
50730         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
50731         int64_t ret_ref = 0;
50732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50733         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50734         return ret_ref;
50735 }
50736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50737         LDKRouteHintHop arg_conv;
50738         arg_conv.inner = untag_ptr(arg);
50739         arg_conv.is_owned = ptr_is_owned(arg);
50740         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50741         arg_conv.is_owned = false;
50742         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
50743         return ret_conv;
50744 }
50745
50746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50747         LDKRouteHintHop orig_conv;
50748         orig_conv.inner = untag_ptr(orig);
50749         orig_conv.is_owned = ptr_is_owned(orig);
50750         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50751         orig_conv.is_owned = false;
50752         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
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
50759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
50760         LDKRouteHintHop o_conv;
50761         o_conv.inner = untag_ptr(o);
50762         o_conv.is_owned = ptr_is_owned(o);
50763         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50764         o_conv.is_owned = false;
50765         int64_t ret_conv = RouteHintHop_hash(&o_conv);
50766         return ret_conv;
50767 }
50768
50769 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50770         LDKRouteHintHop a_conv;
50771         a_conv.inner = untag_ptr(a);
50772         a_conv.is_owned = ptr_is_owned(a);
50773         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50774         a_conv.is_owned = false;
50775         LDKRouteHintHop b_conv;
50776         b_conv.inner = untag_ptr(b);
50777         b_conv.is_owned = ptr_is_owned(b);
50778         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50779         b_conv.is_owned = false;
50780         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
50781         return ret_conv;
50782 }
50783
50784 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
50785         LDKRouteHintHop obj_conv;
50786         obj_conv.inner = untag_ptr(obj);
50787         obj_conv.is_owned = ptr_is_owned(obj);
50788         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50789         obj_conv.is_owned = false;
50790         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
50791         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50792         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50793         CVec_u8Z_free(ret_var);
50794         return ret_arr;
50795 }
50796
50797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50798         LDKu8slice ser_ref;
50799         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50800         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50801         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
50802         *ret_conv = RouteHintHop_read(ser_ref);
50803         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50804         return tag_ptr(ret_conv, true);
50805 }
50806
50807 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) {
50808         LDKPublicKey our_node_pubkey_ref;
50809         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
50810         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
50811         LDKRouteParameters route_params_conv;
50812         route_params_conv.inner = untag_ptr(route_params);
50813         route_params_conv.is_owned = ptr_is_owned(route_params);
50814         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
50815         route_params_conv.is_owned = false;
50816         LDKNetworkGraph network_graph_conv;
50817         network_graph_conv.inner = untag_ptr(network_graph);
50818         network_graph_conv.is_owned = ptr_is_owned(network_graph);
50819         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
50820         network_graph_conv.is_owned = false;
50821         LDKCVec_ChannelDetailsZ first_hops_constr;
50822         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
50823         if (first_hops != NULL) {
50824                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
50825                 if (first_hops_constr.datalen > 0)
50826                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
50827                 else
50828                         first_hops_constr.data = NULL;
50829                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
50830                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
50831                         int64_t first_hops_conv_16 = first_hops_vals[q];
50832                         LDKChannelDetails first_hops_conv_16_conv;
50833                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
50834                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
50835                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
50836                         first_hops_conv_16_conv.is_owned = false;
50837                         first_hops_constr.data[q] = first_hops_conv_16_conv;
50838                 }
50839                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
50840                 first_hops_ptr = &first_hops_constr;
50841         }
50842         void* logger_ptr = untag_ptr(logger);
50843         CHECK_ACCESS(logger_ptr);
50844         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50845         if (logger_conv.free == LDKLogger_JCalls_free) {
50846                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50847                 LDKLogger_JCalls_cloned(&logger_conv);
50848         }
50849         void* scorer_ptr = untag_ptr(scorer);
50850         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
50851         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
50852         uint8_t random_seed_bytes_arr[32];
50853         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
50854         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
50855         uint8_t (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
50856         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
50857         *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);
50858         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
50859         return tag_ptr(ret_conv, true);
50860 }
50861
50862 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) {
50863         LDKPublicKey our_node_pubkey_ref;
50864         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
50865         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
50866         LDKCVec_PublicKeyZ hops_constr;
50867         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
50868         if (hops_constr.datalen > 0)
50869                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
50870         else
50871                 hops_constr.data = NULL;
50872         for (size_t i = 0; i < hops_constr.datalen; i++) {
50873                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
50874                 LDKPublicKey hops_conv_8_ref;
50875                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
50876                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
50877                 hops_constr.data[i] = hops_conv_8_ref;
50878         }
50879         LDKRouteParameters route_params_conv;
50880         route_params_conv.inner = untag_ptr(route_params);
50881         route_params_conv.is_owned = ptr_is_owned(route_params);
50882         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
50883         route_params_conv.is_owned = false;
50884         LDKNetworkGraph network_graph_conv;
50885         network_graph_conv.inner = untag_ptr(network_graph);
50886         network_graph_conv.is_owned = ptr_is_owned(network_graph);
50887         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
50888         network_graph_conv.is_owned = false;
50889         void* logger_ptr = untag_ptr(logger);
50890         CHECK_ACCESS(logger_ptr);
50891         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50892         if (logger_conv.free == LDKLogger_JCalls_free) {
50893                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50894                 LDKLogger_JCalls_cloned(&logger_conv);
50895         }
50896         uint8_t random_seed_bytes_arr[32];
50897         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
50898         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
50899         uint8_t (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
50900         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
50901         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
50902         return tag_ptr(ret_conv, true);
50903 }
50904
50905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50906         if (!ptr_is_owned(this_ptr)) return;
50907         void* this_ptr_ptr = untag_ptr(this_ptr);
50908         CHECK_ACCESS(this_ptr_ptr);
50909         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
50910         FREE(untag_ptr(this_ptr));
50911         Score_free(this_ptr_conv);
50912 }
50913
50914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50915         if (!ptr_is_owned(this_ptr)) return;
50916         void* this_ptr_ptr = untag_ptr(this_ptr);
50917         CHECK_ACCESS(this_ptr_ptr);
50918         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
50919         FREE(untag_ptr(this_ptr));
50920         LockableScore_free(this_ptr_conv);
50921 }
50922
50923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WriteableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50924         if (!ptr_is_owned(this_ptr)) return;
50925         void* this_ptr_ptr = untag_ptr(this_ptr);
50926         CHECK_ACCESS(this_ptr_ptr);
50927         LDKWriteableScore this_ptr_conv = *(LDKWriteableScore*)(this_ptr_ptr);
50928         FREE(untag_ptr(this_ptr));
50929         WriteableScore_free(this_ptr_conv);
50930 }
50931
50932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50933         LDKMultiThreadedLockableScore this_obj_conv;
50934         this_obj_conv.inner = untag_ptr(this_obj);
50935         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50937         MultiThreadedLockableScore_free(this_obj_conv);
50938 }
50939
50940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50941         LDKMultiThreadedScoreLock this_obj_conv;
50942         this_obj_conv.inner = untag_ptr(this_obj);
50943         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50945         MultiThreadedScoreLock_free(this_obj_conv);
50946 }
50947
50948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
50949         LDKMultiThreadedScoreLock this_arg_conv;
50950         this_arg_conv.inner = untag_ptr(this_arg);
50951         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50953         this_arg_conv.is_owned = false;
50954         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
50955         *ret_ret = MultiThreadedScoreLock_as_Score(&this_arg_conv);
50956         return tag_ptr(ret_ret, true);
50957 }
50958
50959 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1write(JNIEnv *env, jclass clz, int64_t obj) {
50960         LDKMultiThreadedScoreLock obj_conv;
50961         obj_conv.inner = untag_ptr(obj);
50962         obj_conv.is_owned = ptr_is_owned(obj);
50963         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50964         obj_conv.is_owned = false;
50965         LDKCVec_u8Z ret_var = MultiThreadedScoreLock_write(&obj_conv);
50966         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50967         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50968         CVec_u8Z_free(ret_var);
50969         return ret_arr;
50970 }
50971
50972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1LockableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
50973         LDKMultiThreadedLockableScore this_arg_conv;
50974         this_arg_conv.inner = untag_ptr(this_arg);
50975         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50977         this_arg_conv.is_owned = false;
50978         LDKLockableScore* ret_ret = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
50979         *ret_ret = MultiThreadedLockableScore_as_LockableScore(&this_arg_conv);
50980         return tag_ptr(ret_ret, true);
50981 }
50982
50983 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
50984         LDKMultiThreadedLockableScore obj_conv;
50985         obj_conv.inner = untag_ptr(obj);
50986         obj_conv.is_owned = ptr_is_owned(obj);
50987         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50988         obj_conv.is_owned = false;
50989         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
50990         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50991         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50992         CVec_u8Z_free(ret_var);
50993         return ret_arr;
50994 }
50995
50996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1WriteableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
50997         LDKMultiThreadedLockableScore this_arg_conv;
50998         this_arg_conv.inner = untag_ptr(this_arg);
50999         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51001         this_arg_conv.is_owned = false;
51002         LDKWriteableScore* ret_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
51003         *ret_ret = MultiThreadedLockableScore_as_WriteableScore(&this_arg_conv);
51004         return tag_ptr(ret_ret, true);
51005 }
51006
51007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
51008         void* score_ptr = untag_ptr(score);
51009         CHECK_ACCESS(score_ptr);
51010         LDKScore score_conv = *(LDKScore*)(score_ptr);
51011         if (score_conv.free == LDKScore_JCalls_free) {
51012                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51013                 LDKScore_JCalls_cloned(&score_conv);
51014         }
51015         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
51016         int64_t ret_ref = 0;
51017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51019         return ret_ref;
51020 }
51021
51022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51023         LDKChannelUsage this_obj_conv;
51024         this_obj_conv.inner = untag_ptr(this_obj);
51025         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51027         ChannelUsage_free(this_obj_conv);
51028 }
51029
51030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
51031         LDKChannelUsage this_ptr_conv;
51032         this_ptr_conv.inner = untag_ptr(this_ptr);
51033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51035         this_ptr_conv.is_owned = false;
51036         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
51037         return ret_conv;
51038 }
51039
51040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51041         LDKChannelUsage this_ptr_conv;
51042         this_ptr_conv.inner = untag_ptr(this_ptr);
51043         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51045         this_ptr_conv.is_owned = false;
51046         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
51047 }
51048
51049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
51050         LDKChannelUsage this_ptr_conv;
51051         this_ptr_conv.inner = untag_ptr(this_ptr);
51052         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51054         this_ptr_conv.is_owned = false;
51055         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
51056         return ret_conv;
51057 }
51058
51059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51060         LDKChannelUsage this_ptr_conv;
51061         this_ptr_conv.inner = untag_ptr(this_ptr);
51062         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51064         this_ptr_conv.is_owned = false;
51065         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
51066 }
51067
51068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
51069         LDKChannelUsage this_ptr_conv;
51070         this_ptr_conv.inner = untag_ptr(this_ptr);
51071         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51073         this_ptr_conv.is_owned = false;
51074         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
51075         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
51076         int64_t ret_ref = tag_ptr(ret_copy, true);
51077         return ret_ref;
51078 }
51079
51080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51081         LDKChannelUsage this_ptr_conv;
51082         this_ptr_conv.inner = untag_ptr(this_ptr);
51083         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51085         this_ptr_conv.is_owned = false;
51086         void* val_ptr = untag_ptr(val);
51087         CHECK_ACCESS(val_ptr);
51088         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
51089         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(val));
51090         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
51091 }
51092
51093 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) {
51094         void* effective_capacity_arg_ptr = untag_ptr(effective_capacity_arg);
51095         CHECK_ACCESS(effective_capacity_arg_ptr);
51096         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
51097         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(effective_capacity_arg));
51098         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
51099         int64_t ret_ref = 0;
51100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51101         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51102         return ret_ref;
51103 }
51104
51105 static inline uint64_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
51106         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
51107         int64_t ret_ref = 0;
51108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51109         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51110         return ret_ref;
51111 }
51112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51113         LDKChannelUsage arg_conv;
51114         arg_conv.inner = untag_ptr(arg);
51115         arg_conv.is_owned = ptr_is_owned(arg);
51116         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51117         arg_conv.is_owned = false;
51118         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
51119         return ret_conv;
51120 }
51121
51122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51123         LDKChannelUsage orig_conv;
51124         orig_conv.inner = untag_ptr(orig);
51125         orig_conv.is_owned = ptr_is_owned(orig);
51126         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51127         orig_conv.is_owned = false;
51128         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
51129         int64_t ret_ref = 0;
51130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51131         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51132         return ret_ref;
51133 }
51134
51135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51136         LDKFixedPenaltyScorer this_obj_conv;
51137         this_obj_conv.inner = untag_ptr(this_obj);
51138         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51140         FixedPenaltyScorer_free(this_obj_conv);
51141 }
51142
51143 static inline uint64_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
51144         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
51145         int64_t ret_ref = 0;
51146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51147         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51148         return ret_ref;
51149 }
51150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51151         LDKFixedPenaltyScorer arg_conv;
51152         arg_conv.inner = untag_ptr(arg);
51153         arg_conv.is_owned = ptr_is_owned(arg);
51154         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51155         arg_conv.is_owned = false;
51156         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
51157         return ret_conv;
51158 }
51159
51160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51161         LDKFixedPenaltyScorer orig_conv;
51162         orig_conv.inner = untag_ptr(orig);
51163         orig_conv.is_owned = ptr_is_owned(orig);
51164         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51165         orig_conv.is_owned = false;
51166         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
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
51173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
51174         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
51175         int64_t ret_ref = 0;
51176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51177         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51178         return ret_ref;
51179 }
51180
51181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
51182         LDKFixedPenaltyScorer this_arg_conv;
51183         this_arg_conv.inner = untag_ptr(this_arg);
51184         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51186         this_arg_conv.is_owned = false;
51187         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
51188         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
51189         return tag_ptr(ret_ret, true);
51190 }
51191
51192 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
51193         LDKFixedPenaltyScorer obj_conv;
51194         obj_conv.inner = untag_ptr(obj);
51195         obj_conv.is_owned = ptr_is_owned(obj);
51196         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51197         obj_conv.is_owned = false;
51198         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
51199         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51200         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51201         CVec_u8Z_free(ret_var);
51202         return ret_arr;
51203 }
51204
51205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
51206         LDKu8slice ser_ref;
51207         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51208         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51209         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
51210         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
51211         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51212         return tag_ptr(ret_conv, true);
51213 }
51214
51215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51216         LDKProbabilisticScorer this_obj_conv;
51217         this_obj_conv.inner = untag_ptr(this_obj);
51218         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51220         ProbabilisticScorer_free(this_obj_conv);
51221 }
51222
51223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51224         LDKProbabilisticScoringParameters this_obj_conv;
51225         this_obj_conv.inner = untag_ptr(this_obj);
51226         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51228         ProbabilisticScoringParameters_free(this_obj_conv);
51229 }
51230
51231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
51232         LDKProbabilisticScoringParameters this_ptr_conv;
51233         this_ptr_conv.inner = untag_ptr(this_ptr);
51234         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51236         this_ptr_conv.is_owned = false;
51237         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
51238         return ret_conv;
51239 }
51240
51241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51242         LDKProbabilisticScoringParameters this_ptr_conv;
51243         this_ptr_conv.inner = untag_ptr(this_ptr);
51244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51246         this_ptr_conv.is_owned = false;
51247         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
51248 }
51249
51250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
51251         LDKProbabilisticScoringParameters this_ptr_conv;
51252         this_ptr_conv.inner = untag_ptr(this_ptr);
51253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51255         this_ptr_conv.is_owned = false;
51256         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
51257         return ret_conv;
51258 }
51259
51260 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) {
51261         LDKProbabilisticScoringParameters 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         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
51267 }
51268
51269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
51270         LDKProbabilisticScoringParameters this_ptr_conv;
51271         this_ptr_conv.inner = untag_ptr(this_ptr);
51272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51274         this_ptr_conv.is_owned = false;
51275         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
51276         return ret_conv;
51277 }
51278
51279 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) {
51280         LDKProbabilisticScoringParameters this_ptr_conv;
51281         this_ptr_conv.inner = untag_ptr(this_ptr);
51282         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51284         this_ptr_conv.is_owned = false;
51285         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
51286 }
51287
51288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
51289         LDKProbabilisticScoringParameters this_ptr_conv;
51290         this_ptr_conv.inner = untag_ptr(this_ptr);
51291         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51293         this_ptr_conv.is_owned = false;
51294         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
51295         return ret_conv;
51296 }
51297
51298 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) {
51299         LDKProbabilisticScoringParameters this_ptr_conv;
51300         this_ptr_conv.inner = untag_ptr(this_ptr);
51301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51303         this_ptr_conv.is_owned = false;
51304         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
51305 }
51306
51307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
51308         LDKProbabilisticScoringParameters this_ptr_conv;
51309         this_ptr_conv.inner = untag_ptr(this_ptr);
51310         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51312         this_ptr_conv.is_owned = false;
51313         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
51314         return ret_conv;
51315 }
51316
51317 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) {
51318         LDKProbabilisticScoringParameters this_ptr_conv;
51319         this_ptr_conv.inner = untag_ptr(this_ptr);
51320         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51322         this_ptr_conv.is_owned = false;
51323         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
51324 }
51325
51326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
51327         LDKProbabilisticScoringParameters this_ptr_conv;
51328         this_ptr_conv.inner = untag_ptr(this_ptr);
51329         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51331         this_ptr_conv.is_owned = false;
51332         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv);
51333         return ret_conv;
51334 }
51335
51336 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) {
51337         LDKProbabilisticScoringParameters this_ptr_conv;
51338         this_ptr_conv.inner = untag_ptr(this_ptr);
51339         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51341         this_ptr_conv.is_owned = false;
51342         ProbabilisticScoringParameters_set_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
51343 }
51344
51345 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) {
51346         LDKProbabilisticScoringParameters this_ptr_conv;
51347         this_ptr_conv.inner = untag_ptr(this_ptr);
51348         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51350         this_ptr_conv.is_owned = false;
51351         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
51352         return ret_conv;
51353 }
51354
51355 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) {
51356         LDKProbabilisticScoringParameters this_ptr_conv;
51357         this_ptr_conv.inner = untag_ptr(this_ptr);
51358         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51360         this_ptr_conv.is_owned = false;
51361         ProbabilisticScoringParameters_set_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
51362 }
51363
51364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1no_1updates_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
51365         LDKProbabilisticScoringParameters this_ptr_conv;
51366         this_ptr_conv.inner = untag_ptr(this_ptr);
51367         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51369         this_ptr_conv.is_owned = false;
51370         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_no_updates_half_life(&this_ptr_conv);
51371         return ret_conv;
51372 }
51373
51374 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) {
51375         LDKProbabilisticScoringParameters this_ptr_conv;
51376         this_ptr_conv.inner = untag_ptr(this_ptr);
51377         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51379         this_ptr_conv.is_owned = false;
51380         ProbabilisticScoringParameters_set_historical_no_updates_half_life(&this_ptr_conv, val);
51381 }
51382
51383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
51384         LDKProbabilisticScoringParameters this_ptr_conv;
51385         this_ptr_conv.inner = untag_ptr(this_ptr);
51386         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51388         this_ptr_conv.is_owned = false;
51389         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
51390         return ret_conv;
51391 }
51392
51393 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) {
51394         LDKProbabilisticScoringParameters this_ptr_conv;
51395         this_ptr_conv.inner = untag_ptr(this_ptr);
51396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51398         this_ptr_conv.is_owned = false;
51399         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
51400 }
51401
51402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
51403         LDKProbabilisticScoringParameters this_ptr_conv;
51404         this_ptr_conv.inner = untag_ptr(this_ptr);
51405         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51407         this_ptr_conv.is_owned = false;
51408         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
51409         return ret_conv;
51410 }
51411
51412 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) {
51413         LDKProbabilisticScoringParameters this_ptr_conv;
51414         this_ptr_conv.inner = untag_ptr(this_ptr);
51415         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51417         this_ptr_conv.is_owned = false;
51418         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
51419 }
51420
51421 static inline uint64_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
51422         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
51423         int64_t ret_ref = 0;
51424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51425         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51426         return ret_ref;
51427 }
51428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51429         LDKProbabilisticScoringParameters arg_conv;
51430         arg_conv.inner = untag_ptr(arg);
51431         arg_conv.is_owned = ptr_is_owned(arg);
51432         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51433         arg_conv.is_owned = false;
51434         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
51435         return ret_conv;
51436 }
51437
51438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51439         LDKProbabilisticScoringParameters orig_conv;
51440         orig_conv.inner = untag_ptr(orig);
51441         orig_conv.is_owned = ptr_is_owned(orig);
51442         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51443         orig_conv.is_owned = false;
51444         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
51445         int64_t ret_ref = 0;
51446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51447         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51448         return ret_ref;
51449 }
51450
51451 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) {
51452         LDKProbabilisticScoringParameters params_conv;
51453         params_conv.inner = untag_ptr(params);
51454         params_conv.is_owned = ptr_is_owned(params);
51455         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
51456         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
51457         LDKNetworkGraph network_graph_conv;
51458         network_graph_conv.inner = untag_ptr(network_graph);
51459         network_graph_conv.is_owned = ptr_is_owned(network_graph);
51460         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
51461         network_graph_conv.is_owned = false;
51462         void* logger_ptr = untag_ptr(logger);
51463         CHECK_ACCESS(logger_ptr);
51464         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51465         if (logger_conv.free == LDKLogger_JCalls_free) {
51466                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51467                 LDKLogger_JCalls_cloned(&logger_conv);
51468         }
51469         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
51470         int64_t ret_ref = 0;
51471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51472         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51473         return ret_ref;
51474 }
51475
51476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
51477         LDKProbabilisticScorer this_arg_conv;
51478         this_arg_conv.inner = untag_ptr(this_arg);
51479         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51481         this_arg_conv.is_owned = false;
51482         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
51483 }
51484
51485 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) {
51486         LDKProbabilisticScorer this_arg_conv;
51487         this_arg_conv.inner = untag_ptr(this_arg);
51488         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51490         this_arg_conv.is_owned = false;
51491         LDKNodeId target_conv;
51492         target_conv.inner = untag_ptr(target);
51493         target_conv.is_owned = ptr_is_owned(target);
51494         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
51495         target_conv.is_owned = false;
51496         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
51497         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
51498         int64_t ret_ref = tag_ptr(ret_copy, true);
51499         return ret_ref;
51500 }
51501
51502 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) {
51503         LDKProbabilisticScorer this_arg_conv;
51504         this_arg_conv.inner = untag_ptr(this_arg);
51505         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51507         this_arg_conv.is_owned = false;
51508         LDKNodeId target_conv;
51509         target_conv.inner = untag_ptr(target);
51510         target_conv.is_owned = ptr_is_owned(target);
51511         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
51512         target_conv.is_owned = false;
51513         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
51514         *ret_copy = ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(&this_arg_conv, scid, &target_conv);
51515         int64_t ret_ref = tag_ptr(ret_copy, true);
51516         return ret_ref;
51517 }
51518
51519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
51520         LDKProbabilisticScorer this_arg_conv;
51521         this_arg_conv.inner = untag_ptr(this_arg);
51522         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51524         this_arg_conv.is_owned = false;
51525         LDKNodeId node_id_conv;
51526         node_id_conv.inner = untag_ptr(node_id);
51527         node_id_conv.is_owned = ptr_is_owned(node_id);
51528         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
51529         node_id_conv.is_owned = false;
51530         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
51531 }
51532
51533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
51534         LDKProbabilisticScorer this_arg_conv;
51535         this_arg_conv.inner = untag_ptr(this_arg);
51536         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51538         this_arg_conv.is_owned = false;
51539         LDKNodeId node_id_conv;
51540         node_id_conv.inner = untag_ptr(node_id);
51541         node_id_conv.is_owned = ptr_is_owned(node_id);
51542         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
51543         node_id_conv.is_owned = false;
51544         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
51545 }
51546
51547 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) {
51548         LDKProbabilisticScorer this_arg_conv;
51549         this_arg_conv.inner = untag_ptr(this_arg);
51550         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51552         this_arg_conv.is_owned = false;
51553         LDKNodeId node_id_conv;
51554         node_id_conv.inner = untag_ptr(node_id);
51555         node_id_conv.is_owned = ptr_is_owned(node_id);
51556         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
51557         node_id_conv.is_owned = false;
51558         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
51559 }
51560
51561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
51562         LDKProbabilisticScorer this_arg_conv;
51563         this_arg_conv.inner = untag_ptr(this_arg);
51564         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51566         this_arg_conv.is_owned = false;
51567         LDKNodeId node_id_conv;
51568         node_id_conv.inner = untag_ptr(node_id);
51569         node_id_conv.is_owned = ptr_is_owned(node_id);
51570         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
51571         node_id_conv.is_owned = false;
51572         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
51573 }
51574
51575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1manual_1penalties(JNIEnv *env, jclass clz, int64_t this_arg) {
51576         LDKProbabilisticScorer this_arg_conv;
51577         this_arg_conv.inner = untag_ptr(this_arg);
51578         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51580         this_arg_conv.is_owned = false;
51581         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
51582 }
51583
51584 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) {
51585         LDKProbabilisticScoringParameters this_arg_conv;
51586         this_arg_conv.inner = untag_ptr(this_arg);
51587         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51589         this_arg_conv.is_owned = false;
51590         LDKCVec_NodeIdZ node_ids_constr;
51591         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
51592         if (node_ids_constr.datalen > 0)
51593                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
51594         else
51595                 node_ids_constr.data = NULL;
51596         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
51597         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
51598                 int64_t node_ids_conv_8 = node_ids_vals[i];
51599                 LDKNodeId node_ids_conv_8_conv;
51600                 node_ids_conv_8_conv.inner = untag_ptr(node_ids_conv_8);
51601                 node_ids_conv_8_conv.is_owned = ptr_is_owned(node_ids_conv_8);
51602                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
51603                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
51604                 node_ids_constr.data[i] = node_ids_conv_8_conv;
51605         }
51606         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
51607         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
51608 }
51609
51610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
51611         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
51612         int64_t ret_ref = 0;
51613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51614         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51615         return ret_ref;
51616 }
51617
51618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
51619         LDKProbabilisticScorer this_arg_conv;
51620         this_arg_conv.inner = untag_ptr(this_arg);
51621         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51623         this_arg_conv.is_owned = false;
51624         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
51625         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
51626         return tag_ptr(ret_ret, true);
51627 }
51628
51629 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
51630         LDKProbabilisticScorer obj_conv;
51631         obj_conv.inner = untag_ptr(obj);
51632         obj_conv.is_owned = ptr_is_owned(obj);
51633         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51634         obj_conv.is_owned = false;
51635         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
51636         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51637         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51638         CVec_u8Z_free(ret_var);
51639         return ret_arr;
51640 }
51641
51642 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) {
51643         LDKu8slice ser_ref;
51644         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51645         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51646         LDKProbabilisticScoringParameters arg_a_conv;
51647         arg_a_conv.inner = untag_ptr(arg_a);
51648         arg_a_conv.is_owned = ptr_is_owned(arg_a);
51649         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
51650         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
51651         LDKNetworkGraph arg_b_conv;
51652         arg_b_conv.inner = untag_ptr(arg_b);
51653         arg_b_conv.is_owned = ptr_is_owned(arg_b);
51654         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
51655         arg_b_conv.is_owned = false;
51656         void* arg_c_ptr = untag_ptr(arg_c);
51657         CHECK_ACCESS(arg_c_ptr);
51658         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
51659         if (arg_c_conv.free == LDKLogger_JCalls_free) {
51660                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51661                 LDKLogger_JCalls_cloned(&arg_c_conv);
51662         }
51663         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
51664         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
51665         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51666         return tag_ptr(ret_conv, true);
51667 }
51668
51669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPath_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51670         LDKBlindedPath this_obj_conv;
51671         this_obj_conv.inner = untag_ptr(this_obj);
51672         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51674         BlindedPath_free(this_obj_conv);
51675 }
51676
51677 static inline uint64_t BlindedPath_clone_ptr(LDKBlindedPath *NONNULL_PTR arg) {
51678         LDKBlindedPath ret_var = BlindedPath_clone(arg);
51679         int64_t ret_ref = 0;
51680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51681         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51682         return ret_ref;
51683 }
51684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51685         LDKBlindedPath arg_conv;
51686         arg_conv.inner = untag_ptr(arg);
51687         arg_conv.is_owned = ptr_is_owned(arg);
51688         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51689         arg_conv.is_owned = false;
51690         int64_t ret_conv = BlindedPath_clone_ptr(&arg_conv);
51691         return ret_conv;
51692 }
51693
51694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51695         LDKBlindedPath orig_conv;
51696         orig_conv.inner = untag_ptr(orig);
51697         orig_conv.is_owned = ptr_is_owned(orig);
51698         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51699         orig_conv.is_owned = false;
51700         LDKBlindedPath ret_var = BlindedPath_clone(&orig_conv);
51701         int64_t ret_ref = 0;
51702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51703         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51704         return ret_ref;
51705 }
51706
51707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51708         LDKBlindedHop this_obj_conv;
51709         this_obj_conv.inner = untag_ptr(this_obj);
51710         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51712         BlindedHop_free(this_obj_conv);
51713 }
51714
51715 static inline uint64_t BlindedHop_clone_ptr(LDKBlindedHop *NONNULL_PTR arg) {
51716         LDKBlindedHop ret_var = BlindedHop_clone(arg);
51717         int64_t ret_ref = 0;
51718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51719         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51720         return ret_ref;
51721 }
51722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51723         LDKBlindedHop arg_conv;
51724         arg_conv.inner = untag_ptr(arg);
51725         arg_conv.is_owned = ptr_is_owned(arg);
51726         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51727         arg_conv.is_owned = false;
51728         int64_t ret_conv = BlindedHop_clone_ptr(&arg_conv);
51729         return ret_conv;
51730 }
51731
51732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51733         LDKBlindedHop orig_conv;
51734         orig_conv.inner = untag_ptr(orig);
51735         orig_conv.is_owned = ptr_is_owned(orig);
51736         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51737         orig_conv.is_owned = false;
51738         LDKBlindedHop ret_var = BlindedHop_clone(&orig_conv);
51739         int64_t ret_ref = 0;
51740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51741         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51742         return ret_ref;
51743 }
51744
51745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1new(JNIEnv *env, jclass clz, jobjectArray node_pks, int64_t entropy_source) {
51746         LDKCVec_PublicKeyZ node_pks_constr;
51747         node_pks_constr.datalen = (*env)->GetArrayLength(env, node_pks);
51748         if (node_pks_constr.datalen > 0)
51749                 node_pks_constr.data = MALLOC(node_pks_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
51750         else
51751                 node_pks_constr.data = NULL;
51752         for (size_t i = 0; i < node_pks_constr.datalen; i++) {
51753                 int8_tArray node_pks_conv_8 = (*env)->GetObjectArrayElement(env, node_pks, i);
51754                 LDKPublicKey node_pks_conv_8_ref;
51755                 CHECK((*env)->GetArrayLength(env, node_pks_conv_8) == 33);
51756                 (*env)->GetByteArrayRegion(env, node_pks_conv_8, 0, 33, node_pks_conv_8_ref.compressed_form);
51757                 node_pks_constr.data[i] = node_pks_conv_8_ref;
51758         }
51759         void* entropy_source_ptr = untag_ptr(entropy_source);
51760         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
51761         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
51762         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
51763         *ret_conv = BlindedPath_new(node_pks_constr, entropy_source_conv);
51764         return tag_ptr(ret_conv, true);
51765 }
51766
51767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedPath_1write(JNIEnv *env, jclass clz, int64_t obj) {
51768         LDKBlindedPath obj_conv;
51769         obj_conv.inner = untag_ptr(obj);
51770         obj_conv.is_owned = ptr_is_owned(obj);
51771         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51772         obj_conv.is_owned = false;
51773         LDKCVec_u8Z ret_var = BlindedPath_write(&obj_conv);
51774         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51775         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51776         CVec_u8Z_free(ret_var);
51777         return ret_arr;
51778 }
51779
51780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51781         LDKu8slice ser_ref;
51782         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51783         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51784         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
51785         *ret_conv = BlindedPath_read(ser_ref);
51786         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51787         return tag_ptr(ret_conv, true);
51788 }
51789
51790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
51791         LDKBlindedHop obj_conv;
51792         obj_conv.inner = untag_ptr(obj);
51793         obj_conv.is_owned = ptr_is_owned(obj);
51794         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51795         obj_conv.is_owned = false;
51796         LDKCVec_u8Z ret_var = BlindedHop_write(&obj_conv);
51797         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51798         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51799         CVec_u8Z_free(ret_var);
51800         return ret_arr;
51801 }
51802
51803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51804         LDKu8slice ser_ref;
51805         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51806         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51807         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
51808         *ret_conv = BlindedHop_read(ser_ref);
51809         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51810         return tag_ptr(ret_conv, true);
51811 }
51812
51813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51814         LDKOnionMessenger this_obj_conv;
51815         this_obj_conv.inner = untag_ptr(this_obj);
51816         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51818         OnionMessenger_free(this_obj_conv);
51819 }
51820
51821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Destination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51822         if (!ptr_is_owned(this_ptr)) return;
51823         void* this_ptr_ptr = untag_ptr(this_ptr);
51824         CHECK_ACCESS(this_ptr_ptr);
51825         LDKDestination this_ptr_conv = *(LDKDestination*)(this_ptr_ptr);
51826         FREE(untag_ptr(this_ptr));
51827         Destination_free(this_ptr_conv);
51828 }
51829
51830 static inline uint64_t Destination_clone_ptr(LDKDestination *NONNULL_PTR arg) {
51831         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
51832         *ret_copy = Destination_clone(arg);
51833         int64_t ret_ref = tag_ptr(ret_copy, true);
51834         return ret_ref;
51835 }
51836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51837         LDKDestination* arg_conv = (LDKDestination*)untag_ptr(arg);
51838         int64_t ret_conv = Destination_clone_ptr(arg_conv);
51839         return ret_conv;
51840 }
51841
51842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51843         LDKDestination* orig_conv = (LDKDestination*)untag_ptr(orig);
51844         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
51845         *ret_copy = Destination_clone(orig_conv);
51846         int64_t ret_ref = tag_ptr(ret_copy, true);
51847         return ret_ref;
51848 }
51849
51850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1node(JNIEnv *env, jclass clz, int8_tArray a) {
51851         LDKPublicKey a_ref;
51852         CHECK((*env)->GetArrayLength(env, a) == 33);
51853         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
51854         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
51855         *ret_copy = Destination_node(a_ref);
51856         int64_t ret_ref = tag_ptr(ret_copy, true);
51857         return ret_ref;
51858 }
51859
51860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1blinded_1path(JNIEnv *env, jclass clz, int64_t a) {
51861         LDKBlindedPath a_conv;
51862         a_conv.inner = untag_ptr(a);
51863         a_conv.is_owned = ptr_is_owned(a);
51864         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51865         a_conv = BlindedPath_clone(&a_conv);
51866         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
51867         *ret_copy = Destination_blinded_path(a_conv);
51868         int64_t ret_ref = tag_ptr(ret_copy, true);
51869         return ret_ref;
51870 }
51871
51872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SendError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51873         if (!ptr_is_owned(this_ptr)) return;
51874         void* this_ptr_ptr = untag_ptr(this_ptr);
51875         CHECK_ACCESS(this_ptr_ptr);
51876         LDKSendError this_ptr_conv = *(LDKSendError*)(this_ptr_ptr);
51877         FREE(untag_ptr(this_ptr));
51878         SendError_free(this_ptr_conv);
51879 }
51880
51881 static inline uint64_t SendError_clone_ptr(LDKSendError *NONNULL_PTR arg) {
51882         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
51883         *ret_copy = SendError_clone(arg);
51884         int64_t ret_ref = tag_ptr(ret_copy, true);
51885         return ret_ref;
51886 }
51887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51888         LDKSendError* arg_conv = (LDKSendError*)untag_ptr(arg);
51889         int64_t ret_conv = SendError_clone_ptr(arg_conv);
51890         return ret_conv;
51891 }
51892
51893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51894         LDKSendError* orig_conv = (LDKSendError*)untag_ptr(orig);
51895         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
51896         *ret_copy = SendError_clone(orig_conv);
51897         int64_t ret_ref = tag_ptr(ret_copy, true);
51898         return ret_ref;
51899 }
51900
51901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1secp256k1(JNIEnv *env, jclass clz, jclass a) {
51902         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
51903         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
51904         *ret_copy = SendError_secp256k1(a_conv);
51905         int64_t ret_ref = tag_ptr(ret_copy, true);
51906         return ret_ref;
51907 }
51908
51909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1big_1packet(JNIEnv *env, jclass clz) {
51910         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
51911         *ret_copy = SendError_too_big_packet();
51912         int64_t ret_ref = tag_ptr(ret_copy, true);
51913         return ret_ref;
51914 }
51915
51916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1few_1blinded_1hops(JNIEnv *env, jclass clz) {
51917         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
51918         *ret_copy = SendError_too_few_blinded_hops();
51919         int64_t ret_ref = tag_ptr(ret_copy, true);
51920         return ret_ref;
51921 }
51922
51923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1first_1hop(JNIEnv *env, jclass clz) {
51924         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
51925         *ret_copy = SendError_invalid_first_hop();
51926         int64_t ret_ref = tag_ptr(ret_copy, true);
51927         return ret_ref;
51928 }
51929
51930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1message(JNIEnv *env, jclass clz) {
51931         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
51932         *ret_copy = SendError_invalid_message();
51933         int64_t ret_ref = tag_ptr(ret_copy, true);
51934         return ret_ref;
51935 }
51936
51937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1buffer_1full(JNIEnv *env, jclass clz) {
51938         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
51939         *ret_copy = SendError_buffer_full();
51940         int64_t ret_ref = tag_ptr(ret_copy, true);
51941         return ret_ref;
51942 }
51943
51944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1get_1node_1id_1failed(JNIEnv *env, jclass clz) {
51945         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
51946         *ret_copy = SendError_get_node_id_failed();
51947         int64_t ret_ref = tag_ptr(ret_copy, true);
51948         return ret_ref;
51949 }
51950
51951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1blinded_1path_1advance_1failed(JNIEnv *env, jclass clz) {
51952         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
51953         *ret_copy = SendError_blinded_path_advance_failed();
51954         int64_t ret_ref = tag_ptr(ret_copy, true);
51955         return ret_ref;
51956 }
51957
51958 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SendError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51959         LDKSendError* a_conv = (LDKSendError*)untag_ptr(a);
51960         LDKSendError* b_conv = (LDKSendError*)untag_ptr(b);
51961         jboolean ret_conv = SendError_eq(a_conv, b_conv);
51962         return ret_conv;
51963 }
51964
51965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51966         if (!ptr_is_owned(this_ptr)) return;
51967         void* this_ptr_ptr = untag_ptr(this_ptr);
51968         CHECK_ACCESS(this_ptr_ptr);
51969         LDKCustomOnionMessageHandler this_ptr_conv = *(LDKCustomOnionMessageHandler*)(this_ptr_ptr);
51970         FREE(untag_ptr(this_ptr));
51971         CustomOnionMessageHandler_free(this_ptr_conv);
51972 }
51973
51974 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) {
51975         void* entropy_source_ptr = untag_ptr(entropy_source);
51976         CHECK_ACCESS(entropy_source_ptr);
51977         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
51978         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
51979                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51980                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
51981         }
51982         void* node_signer_ptr = untag_ptr(node_signer);
51983         CHECK_ACCESS(node_signer_ptr);
51984         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
51985         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
51986                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51987                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
51988         }
51989         void* logger_ptr = untag_ptr(logger);
51990         CHECK_ACCESS(logger_ptr);
51991         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51992         if (logger_conv.free == LDKLogger_JCalls_free) {
51993                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51994                 LDKLogger_JCalls_cloned(&logger_conv);
51995         }
51996         void* custom_handler_ptr = untag_ptr(custom_handler);
51997         CHECK_ACCESS(custom_handler_ptr);
51998         LDKCustomOnionMessageHandler custom_handler_conv = *(LDKCustomOnionMessageHandler*)(custom_handler_ptr);
51999         if (custom_handler_conv.free == LDKCustomOnionMessageHandler_JCalls_free) {
52000                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52001                 LDKCustomOnionMessageHandler_JCalls_cloned(&custom_handler_conv);
52002         }
52003         LDKOnionMessenger ret_var = OnionMessenger_new(entropy_source_conv, node_signer_conv, logger_conv, custom_handler_conv);
52004         int64_t ret_ref = 0;
52005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52006         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52007         return ret_ref;
52008 }
52009
52010 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) {
52011         LDKOnionMessenger this_arg_conv;
52012         this_arg_conv.inner = untag_ptr(this_arg);
52013         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52015         this_arg_conv.is_owned = false;
52016         LDKCVec_PublicKeyZ intermediate_nodes_constr;
52017         intermediate_nodes_constr.datalen = (*env)->GetArrayLength(env, intermediate_nodes);
52018         if (intermediate_nodes_constr.datalen > 0)
52019                 intermediate_nodes_constr.data = MALLOC(intermediate_nodes_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
52020         else
52021                 intermediate_nodes_constr.data = NULL;
52022         for (size_t i = 0; i < intermediate_nodes_constr.datalen; i++) {
52023                 int8_tArray intermediate_nodes_conv_8 = (*env)->GetObjectArrayElement(env, intermediate_nodes, i);
52024                 LDKPublicKey intermediate_nodes_conv_8_ref;
52025                 CHECK((*env)->GetArrayLength(env, intermediate_nodes_conv_8) == 33);
52026                 (*env)->GetByteArrayRegion(env, intermediate_nodes_conv_8, 0, 33, intermediate_nodes_conv_8_ref.compressed_form);
52027                 intermediate_nodes_constr.data[i] = intermediate_nodes_conv_8_ref;
52028         }
52029         void* destination_ptr = untag_ptr(destination);
52030         CHECK_ACCESS(destination_ptr);
52031         LDKDestination destination_conv = *(LDKDestination*)(destination_ptr);
52032         destination_conv = Destination_clone((LDKDestination*)untag_ptr(destination));
52033         void* message_ptr = untag_ptr(message);
52034         CHECK_ACCESS(message_ptr);
52035         LDKOnionMessageContents message_conv = *(LDKOnionMessageContents*)(message_ptr);
52036         message_conv = OnionMessageContents_clone((LDKOnionMessageContents*)untag_ptr(message));
52037         LDKBlindedPath reply_path_conv;
52038         reply_path_conv.inner = untag_ptr(reply_path);
52039         reply_path_conv.is_owned = ptr_is_owned(reply_path);
52040         CHECK_INNER_FIELD_ACCESS_OR_NULL(reply_path_conv);
52041         reply_path_conv = BlindedPath_clone(&reply_path_conv);
52042         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
52043         *ret_conv = OnionMessenger_send_onion_message(&this_arg_conv, intermediate_nodes_constr, destination_conv, message_conv, reply_path_conv);
52044         return tag_ptr(ret_conv, true);
52045 }
52046
52047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
52048         LDKOnionMessenger this_arg_conv;
52049         this_arg_conv.inner = untag_ptr(this_arg);
52050         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52052         this_arg_conv.is_owned = false;
52053         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
52054         *ret_ret = OnionMessenger_as_OnionMessageHandler(&this_arg_conv);
52055         return tag_ptr(ret_ret, true);
52056 }
52057
52058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
52059         LDKOnionMessenger this_arg_conv;
52060         this_arg_conv.inner = untag_ptr(this_arg);
52061         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52063         this_arg_conv.is_owned = false;
52064         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
52065         *ret_ret = OnionMessenger_as_OnionMessageProvider(&this_arg_conv);
52066         return tag_ptr(ret_ret, true);
52067 }
52068
52069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52070         if (!ptr_is_owned(this_ptr)) return;
52071         void* this_ptr_ptr = untag_ptr(this_ptr);
52072         CHECK_ACCESS(this_ptr_ptr);
52073         LDKOnionMessageContents this_ptr_conv = *(LDKOnionMessageContents*)(this_ptr_ptr);
52074         FREE(untag_ptr(this_ptr));
52075         OnionMessageContents_free(this_ptr_conv);
52076 }
52077
52078 static inline uint64_t OnionMessageContents_clone_ptr(LDKOnionMessageContents *NONNULL_PTR arg) {
52079         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
52080         *ret_copy = OnionMessageContents_clone(arg);
52081         int64_t ret_ref = tag_ptr(ret_copy, true);
52082         return ret_ref;
52083 }
52084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52085         LDKOnionMessageContents* arg_conv = (LDKOnionMessageContents*)untag_ptr(arg);
52086         int64_t ret_conv = OnionMessageContents_clone_ptr(arg_conv);
52087         return ret_conv;
52088 }
52089
52090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52091         LDKOnionMessageContents* orig_conv = (LDKOnionMessageContents*)untag_ptr(orig);
52092         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
52093         *ret_copy = OnionMessageContents_clone(orig_conv);
52094         int64_t ret_ref = tag_ptr(ret_copy, true);
52095         return ret_ref;
52096 }
52097
52098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1custom(JNIEnv *env, jclass clz, int64_t a) {
52099         void* a_ptr = untag_ptr(a);
52100         CHECK_ACCESS(a_ptr);
52101         LDKCustomOnionMessageContents a_conv = *(LDKCustomOnionMessageContents*)(a_ptr);
52102         if (a_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
52103                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52104                 LDKCustomOnionMessageContents_JCalls_cloned(&a_conv);
52105         }
52106         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
52107         *ret_copy = OnionMessageContents_custom(a_conv);
52108         int64_t ret_ref = tag_ptr(ret_copy, true);
52109         return ret_ref;
52110 }
52111
52112 static inline uint64_t CustomOnionMessageContents_clone_ptr(LDKCustomOnionMessageContents *NONNULL_PTR arg) {
52113         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
52114         *ret_ret = CustomOnionMessageContents_clone(arg);
52115         return tag_ptr(ret_ret, true);
52116 }
52117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52118         void* arg_ptr = untag_ptr(arg);
52119         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
52120         LDKCustomOnionMessageContents* arg_conv = (LDKCustomOnionMessageContents*)arg_ptr;
52121         int64_t ret_conv = CustomOnionMessageContents_clone_ptr(arg_conv);
52122         return ret_conv;
52123 }
52124
52125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52126         void* orig_ptr = untag_ptr(orig);
52127         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
52128         LDKCustomOnionMessageContents* orig_conv = (LDKCustomOnionMessageContents*)orig_ptr;
52129         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
52130         *ret_ret = CustomOnionMessageContents_clone(orig_conv);
52131         return tag_ptr(ret_ret, true);
52132 }
52133
52134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52135         if (!ptr_is_owned(this_ptr)) return;
52136         void* this_ptr_ptr = untag_ptr(this_ptr);
52137         CHECK_ACCESS(this_ptr_ptr);
52138         LDKCustomOnionMessageContents this_ptr_conv = *(LDKCustomOnionMessageContents*)(this_ptr_ptr);
52139         FREE(untag_ptr(this_ptr));
52140         CustomOnionMessageContents_free(this_ptr_conv);
52141 }
52142
52143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52144         LDKFilesystemPersister this_obj_conv;
52145         this_obj_conv.inner = untag_ptr(this_obj);
52146         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52148         FilesystemPersister_free(this_obj_conv);
52149 }
52150
52151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
52152         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
52153         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
52154         int64_t ret_ref = 0;
52155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52156         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52157         return ret_ref;
52158 }
52159
52160 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
52161         LDKFilesystemPersister this_arg_conv;
52162         this_arg_conv.inner = untag_ptr(this_arg);
52163         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52165         this_arg_conv.is_owned = false;
52166         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
52167         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
52168         Str_free(ret_str);
52169         return ret_conv;
52170 }
52171
52172 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) {
52173         LDKFilesystemPersister this_arg_conv;
52174         this_arg_conv.inner = untag_ptr(this_arg);
52175         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52177         this_arg_conv.is_owned = false;
52178         void* entropy_source_ptr = untag_ptr(entropy_source);
52179         CHECK_ACCESS(entropy_source_ptr);
52180         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
52181         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
52182                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52183                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
52184         }
52185         void* signer_provider_ptr = untag_ptr(signer_provider);
52186         if (ptr_is_owned(signer_provider)) { CHECK_ACCESS(signer_provider_ptr); }
52187         LDKSignerProvider* signer_provider_conv = (LDKSignerProvider*)signer_provider_ptr;
52188         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
52189         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, entropy_source_conv, signer_provider_conv);
52190         return tag_ptr(ret_conv, true);
52191 }
52192
52193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52194         LDKBackgroundProcessor this_obj_conv;
52195         this_obj_conv.inner = untag_ptr(this_obj);
52196         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52198         BackgroundProcessor_free(this_obj_conv);
52199 }
52200
52201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52202         if (!ptr_is_owned(this_ptr)) return;
52203         void* this_ptr_ptr = untag_ptr(this_ptr);
52204         CHECK_ACCESS(this_ptr_ptr);
52205         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
52206         FREE(untag_ptr(this_ptr));
52207         GossipSync_free(this_ptr_conv);
52208 }
52209
52210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
52211         LDKP2PGossipSync a_conv;
52212         a_conv.inner = untag_ptr(a);
52213         a_conv.is_owned = ptr_is_owned(a);
52214         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52215         a_conv.is_owned = false;
52216         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
52217         *ret_copy = GossipSync_p2_p(&a_conv);
52218         int64_t ret_ref = tag_ptr(ret_copy, true);
52219         return ret_ref;
52220 }
52221
52222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
52223         LDKRapidGossipSync a_conv;
52224         a_conv.inner = untag_ptr(a);
52225         a_conv.is_owned = ptr_is_owned(a);
52226         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52227         a_conv.is_owned = false;
52228         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
52229         *ret_copy = GossipSync_rapid(&a_conv);
52230         int64_t ret_ref = tag_ptr(ret_copy, true);
52231         return ret_ref;
52232 }
52233
52234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
52235         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
52236         *ret_copy = GossipSync_none();
52237         int64_t ret_ref = tag_ptr(ret_copy, true);
52238         return ret_ref;
52239 }
52240
52241 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) {
52242         void* persister_ptr = untag_ptr(persister);
52243         CHECK_ACCESS(persister_ptr);
52244         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
52245         if (persister_conv.free == LDKPersister_JCalls_free) {
52246                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52247                 LDKPersister_JCalls_cloned(&persister_conv);
52248         }
52249         void* event_handler_ptr = untag_ptr(event_handler);
52250         CHECK_ACCESS(event_handler_ptr);
52251         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
52252         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
52253                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52254                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
52255         }
52256         LDKChainMonitor chain_monitor_conv;
52257         chain_monitor_conv.inner = untag_ptr(chain_monitor);
52258         chain_monitor_conv.is_owned = ptr_is_owned(chain_monitor);
52259         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
52260         chain_monitor_conv.is_owned = false;
52261         LDKChannelManager channel_manager_conv;
52262         channel_manager_conv.inner = untag_ptr(channel_manager);
52263         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
52264         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
52265         channel_manager_conv.is_owned = false;
52266         void* gossip_sync_ptr = untag_ptr(gossip_sync);
52267         CHECK_ACCESS(gossip_sync_ptr);
52268         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
52269         // WARNING: we may need a move here but no clone is available for LDKGossipSync
52270         LDKPeerManager peer_manager_conv;
52271         peer_manager_conv.inner = untag_ptr(peer_manager);
52272         peer_manager_conv.is_owned = ptr_is_owned(peer_manager);
52273         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
52274         peer_manager_conv.is_owned = false;
52275         void* logger_ptr = untag_ptr(logger);
52276         CHECK_ACCESS(logger_ptr);
52277         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
52278         if (logger_conv.free == LDKLogger_JCalls_free) {
52279                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52280                 LDKLogger_JCalls_cloned(&logger_conv);
52281         }
52282         void* scorer_ptr = untag_ptr(scorer);
52283         CHECK_ACCESS(scorer_ptr);
52284         LDKCOption_WriteableScoreZ scorer_conv = *(LDKCOption_WriteableScoreZ*)(scorer_ptr);
52285         // WARNING: we may need a move here but no clone is available for LDKCOption_WriteableScoreZ
52286         if (scorer_conv.tag == LDKCOption_WriteableScoreZ_Some) {
52287                 // Manually implement clone for Java trait instances
52288                 if (scorer_conv.some.free == LDKWriteableScore_JCalls_free) {
52289                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52290                         LDKWriteableScore_JCalls_cloned(&scorer_conv.some);
52291                 }
52292         }
52293         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);
52294         int64_t ret_ref = 0;
52295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52296         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52297         return ret_ref;
52298 }
52299
52300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
52301         LDKBackgroundProcessor this_arg_conv;
52302         this_arg_conv.inner = untag_ptr(this_arg);
52303         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52305         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
52306         
52307         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
52308         *ret_conv = BackgroundProcessor_join(this_arg_conv);
52309         return tag_ptr(ret_conv, true);
52310 }
52311
52312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
52313         LDKBackgroundProcessor this_arg_conv;
52314         this_arg_conv.inner = untag_ptr(this_arg);
52315         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52317         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
52318         
52319         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
52320         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
52321         return tag_ptr(ret_conv, true);
52322 }
52323
52324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52325         if (!ptr_is_owned(this_ptr)) return;
52326         void* this_ptr_ptr = untag_ptr(this_ptr);
52327         CHECK_ACCESS(this_ptr_ptr);
52328         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
52329         FREE(untag_ptr(this_ptr));
52330         ParseError_free(this_ptr_conv);
52331 }
52332
52333 static inline uint64_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
52334         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52335         *ret_copy = ParseError_clone(arg);
52336         int64_t ret_ref = tag_ptr(ret_copy, true);
52337         return ret_ref;
52338 }
52339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52340         LDKParseError* arg_conv = (LDKParseError*)untag_ptr(arg);
52341         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
52342         return ret_conv;
52343 }
52344
52345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52346         LDKParseError* orig_conv = (LDKParseError*)untag_ptr(orig);
52347         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52348         *ret_copy = ParseError_clone(orig_conv);
52349         int64_t ret_ref = tag_ptr(ret_copy, true);
52350         return ret_ref;
52351 }
52352
52353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
52354         void* a_ptr = untag_ptr(a);
52355         CHECK_ACCESS(a_ptr);
52356         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
52357         a_conv = Bech32Error_clone((LDKBech32Error*)untag_ptr(a));
52358         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52359         *ret_copy = ParseError_bech32_error(a_conv);
52360         int64_t ret_ref = tag_ptr(ret_copy, true);
52361         return ret_ref;
52362 }
52363
52364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
52365         
52366         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52367         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
52368         int64_t ret_ref = tag_ptr(ret_copy, true);
52369         return ret_ref;
52370 }
52371
52372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
52373         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
52374         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52375         *ret_copy = ParseError_malformed_signature(a_conv);
52376         int64_t ret_ref = tag_ptr(ret_copy, true);
52377         return ret_ref;
52378 }
52379
52380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
52381         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52382         *ret_copy = ParseError_bad_prefix();
52383         int64_t ret_ref = tag_ptr(ret_copy, true);
52384         return ret_ref;
52385 }
52386
52387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
52388         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52389         *ret_copy = ParseError_unknown_currency();
52390         int64_t ret_ref = tag_ptr(ret_copy, true);
52391         return ret_ref;
52392 }
52393
52394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
52395         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52396         *ret_copy = ParseError_unknown_si_prefix();
52397         int64_t ret_ref = tag_ptr(ret_copy, true);
52398         return ret_ref;
52399 }
52400
52401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
52402         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52403         *ret_copy = ParseError_malformed_hrp();
52404         int64_t ret_ref = tag_ptr(ret_copy, true);
52405         return ret_ref;
52406 }
52407
52408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
52409         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52410         *ret_copy = ParseError_too_short_data_part();
52411         int64_t ret_ref = tag_ptr(ret_copy, true);
52412         return ret_ref;
52413 }
52414
52415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
52416         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52417         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
52418         int64_t ret_ref = tag_ptr(ret_copy, true);
52419         return ret_ref;
52420 }
52421
52422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
52423         
52424         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52425         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
52426         int64_t ret_ref = tag_ptr(ret_copy, true);
52427         return ret_ref;
52428 }
52429
52430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
52431         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52432         *ret_copy = ParseError_padding_error();
52433         int64_t ret_ref = tag_ptr(ret_copy, true);
52434         return ret_ref;
52435 }
52436
52437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
52438         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52439         *ret_copy = ParseError_integer_overflow_error();
52440         int64_t ret_ref = tag_ptr(ret_copy, true);
52441         return ret_ref;
52442 }
52443
52444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
52445         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52446         *ret_copy = ParseError_invalid_seg_wit_program_length();
52447         int64_t ret_ref = tag_ptr(ret_copy, true);
52448         return ret_ref;
52449 }
52450
52451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
52452         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52453         *ret_copy = ParseError_invalid_pub_key_hash_length();
52454         int64_t ret_ref = tag_ptr(ret_copy, true);
52455         return ret_ref;
52456 }
52457
52458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
52459         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52460         *ret_copy = ParseError_invalid_script_hash_length();
52461         int64_t ret_ref = tag_ptr(ret_copy, true);
52462         return ret_ref;
52463 }
52464
52465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
52466         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52467         *ret_copy = ParseError_invalid_recovery_id();
52468         int64_t ret_ref = tag_ptr(ret_copy, true);
52469         return ret_ref;
52470 }
52471
52472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
52473         LDKStr a_conv = java_to_owned_str(env, a);
52474         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52475         *ret_copy = ParseError_invalid_slice_length(a_conv);
52476         int64_t ret_ref = tag_ptr(ret_copy, true);
52477         return ret_ref;
52478 }
52479
52480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
52481         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
52482         *ret_copy = ParseError_skip();
52483         int64_t ret_ref = tag_ptr(ret_copy, true);
52484         return ret_ref;
52485 }
52486
52487 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52488         LDKParseError* a_conv = (LDKParseError*)untag_ptr(a);
52489         LDKParseError* b_conv = (LDKParseError*)untag_ptr(b);
52490         jboolean ret_conv = ParseError_eq(a_conv, b_conv);
52491         return ret_conv;
52492 }
52493
52494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52495         if (!ptr_is_owned(this_ptr)) return;
52496         void* this_ptr_ptr = untag_ptr(this_ptr);
52497         CHECK_ACCESS(this_ptr_ptr);
52498         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
52499         FREE(untag_ptr(this_ptr));
52500         ParseOrSemanticError_free(this_ptr_conv);
52501 }
52502
52503 static inline uint64_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
52504         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
52505         *ret_copy = ParseOrSemanticError_clone(arg);
52506         int64_t ret_ref = tag_ptr(ret_copy, true);
52507         return ret_ref;
52508 }
52509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52510         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)untag_ptr(arg);
52511         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
52512         return ret_conv;
52513 }
52514
52515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52516         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)untag_ptr(orig);
52517         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
52518         *ret_copy = ParseOrSemanticError_clone(orig_conv);
52519         int64_t ret_ref = tag_ptr(ret_copy, true);
52520         return ret_ref;
52521 }
52522
52523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
52524         void* a_ptr = untag_ptr(a);
52525         CHECK_ACCESS(a_ptr);
52526         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
52527         a_conv = ParseError_clone((LDKParseError*)untag_ptr(a));
52528         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
52529         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
52530         int64_t ret_ref = tag_ptr(ret_copy, true);
52531         return ret_ref;
52532 }
52533
52534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
52535         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
52536         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
52537         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
52538         int64_t ret_ref = tag_ptr(ret_copy, true);
52539         return ret_ref;
52540 }
52541
52542 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52543         LDKParseOrSemanticError* a_conv = (LDKParseOrSemanticError*)untag_ptr(a);
52544         LDKParseOrSemanticError* b_conv = (LDKParseOrSemanticError*)untag_ptr(b);
52545         jboolean ret_conv = ParseOrSemanticError_eq(a_conv, b_conv);
52546         return ret_conv;
52547 }
52548
52549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52550         LDKInvoice this_obj_conv;
52551         this_obj_conv.inner = untag_ptr(this_obj);
52552         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52554         Invoice_free(this_obj_conv);
52555 }
52556
52557 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52558         LDKInvoice a_conv;
52559         a_conv.inner = untag_ptr(a);
52560         a_conv.is_owned = ptr_is_owned(a);
52561         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52562         a_conv.is_owned = false;
52563         LDKInvoice b_conv;
52564         b_conv.inner = untag_ptr(b);
52565         b_conv.is_owned = ptr_is_owned(b);
52566         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52567         b_conv.is_owned = false;
52568         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
52569         return ret_conv;
52570 }
52571
52572 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
52573         LDKInvoice ret_var = Invoice_clone(arg);
52574         int64_t ret_ref = 0;
52575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52576         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52577         return ret_ref;
52578 }
52579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52580         LDKInvoice arg_conv;
52581         arg_conv.inner = untag_ptr(arg);
52582         arg_conv.is_owned = ptr_is_owned(arg);
52583         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52584         arg_conv.is_owned = false;
52585         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
52586         return ret_conv;
52587 }
52588
52589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52590         LDKInvoice orig_conv;
52591         orig_conv.inner = untag_ptr(orig);
52592         orig_conv.is_owned = ptr_is_owned(orig);
52593         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52594         orig_conv.is_owned = false;
52595         LDKInvoice ret_var = Invoice_clone(&orig_conv);
52596         int64_t ret_ref = 0;
52597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52598         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52599         return ret_ref;
52600 }
52601
52602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
52603         LDKInvoice o_conv;
52604         o_conv.inner = untag_ptr(o);
52605         o_conv.is_owned = ptr_is_owned(o);
52606         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52607         o_conv.is_owned = false;
52608         int64_t ret_conv = Invoice_hash(&o_conv);
52609         return ret_conv;
52610 }
52611
52612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52613         LDKSignedRawInvoice this_obj_conv;
52614         this_obj_conv.inner = untag_ptr(this_obj);
52615         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52617         SignedRawInvoice_free(this_obj_conv);
52618 }
52619
52620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52621         LDKSignedRawInvoice a_conv;
52622         a_conv.inner = untag_ptr(a);
52623         a_conv.is_owned = ptr_is_owned(a);
52624         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52625         a_conv.is_owned = false;
52626         LDKSignedRawInvoice b_conv;
52627         b_conv.inner = untag_ptr(b);
52628         b_conv.is_owned = ptr_is_owned(b);
52629         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52630         b_conv.is_owned = false;
52631         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
52632         return ret_conv;
52633 }
52634
52635 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
52636         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
52637         int64_t ret_ref = 0;
52638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52639         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52640         return ret_ref;
52641 }
52642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52643         LDKSignedRawInvoice arg_conv;
52644         arg_conv.inner = untag_ptr(arg);
52645         arg_conv.is_owned = ptr_is_owned(arg);
52646         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52647         arg_conv.is_owned = false;
52648         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
52649         return ret_conv;
52650 }
52651
52652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52653         LDKSignedRawInvoice orig_conv;
52654         orig_conv.inner = untag_ptr(orig);
52655         orig_conv.is_owned = ptr_is_owned(orig);
52656         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52657         orig_conv.is_owned = false;
52658         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
52659         int64_t ret_ref = 0;
52660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52661         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52662         return ret_ref;
52663 }
52664
52665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
52666         LDKSignedRawInvoice o_conv;
52667         o_conv.inner = untag_ptr(o);
52668         o_conv.is_owned = ptr_is_owned(o);
52669         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52670         o_conv.is_owned = false;
52671         int64_t ret_conv = SignedRawInvoice_hash(&o_conv);
52672         return ret_conv;
52673 }
52674
52675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52676         LDKRawInvoice this_obj_conv;
52677         this_obj_conv.inner = untag_ptr(this_obj);
52678         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52680         RawInvoice_free(this_obj_conv);
52681 }
52682
52683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
52684         LDKRawInvoice this_ptr_conv;
52685         this_ptr_conv.inner = untag_ptr(this_ptr);
52686         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52688         this_ptr_conv.is_owned = false;
52689         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
52690         int64_t ret_ref = 0;
52691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52692         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52693         return ret_ref;
52694 }
52695
52696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52697         LDKRawInvoice 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         LDKRawDataPart val_conv;
52703         val_conv.inner = untag_ptr(val);
52704         val_conv.is_owned = ptr_is_owned(val);
52705         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
52706         val_conv = RawDataPart_clone(&val_conv);
52707         RawInvoice_set_data(&this_ptr_conv, val_conv);
52708 }
52709
52710 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52711         LDKRawInvoice a_conv;
52712         a_conv.inner = untag_ptr(a);
52713         a_conv.is_owned = ptr_is_owned(a);
52714         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52715         a_conv.is_owned = false;
52716         LDKRawInvoice b_conv;
52717         b_conv.inner = untag_ptr(b);
52718         b_conv.is_owned = ptr_is_owned(b);
52719         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52720         b_conv.is_owned = false;
52721         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
52722         return ret_conv;
52723 }
52724
52725 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
52726         LDKRawInvoice ret_var = RawInvoice_clone(arg);
52727         int64_t ret_ref = 0;
52728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52729         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52730         return ret_ref;
52731 }
52732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52733         LDKRawInvoice arg_conv;
52734         arg_conv.inner = untag_ptr(arg);
52735         arg_conv.is_owned = ptr_is_owned(arg);
52736         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52737         arg_conv.is_owned = false;
52738         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
52739         return ret_conv;
52740 }
52741
52742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52743         LDKRawInvoice orig_conv;
52744         orig_conv.inner = untag_ptr(orig);
52745         orig_conv.is_owned = ptr_is_owned(orig);
52746         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52747         orig_conv.is_owned = false;
52748         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
52749         int64_t ret_ref = 0;
52750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52751         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52752         return ret_ref;
52753 }
52754
52755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
52756         LDKRawInvoice o_conv;
52757         o_conv.inner = untag_ptr(o);
52758         o_conv.is_owned = ptr_is_owned(o);
52759         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52760         o_conv.is_owned = false;
52761         int64_t ret_conv = RawInvoice_hash(&o_conv);
52762         return ret_conv;
52763 }
52764
52765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52766         LDKRawDataPart this_obj_conv;
52767         this_obj_conv.inner = untag_ptr(this_obj);
52768         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52770         RawDataPart_free(this_obj_conv);
52771 }
52772
52773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
52774         LDKRawDataPart this_ptr_conv;
52775         this_ptr_conv.inner = untag_ptr(this_ptr);
52776         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52778         this_ptr_conv.is_owned = false;
52779         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
52780         int64_t ret_ref = 0;
52781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52782         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52783         return ret_ref;
52784 }
52785
52786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52787         LDKRawDataPart this_ptr_conv;
52788         this_ptr_conv.inner = untag_ptr(this_ptr);
52789         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52791         this_ptr_conv.is_owned = false;
52792         LDKPositiveTimestamp val_conv;
52793         val_conv.inner = untag_ptr(val);
52794         val_conv.is_owned = ptr_is_owned(val);
52795         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
52796         val_conv = PositiveTimestamp_clone(&val_conv);
52797         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
52798 }
52799
52800 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52801         LDKRawDataPart a_conv;
52802         a_conv.inner = untag_ptr(a);
52803         a_conv.is_owned = ptr_is_owned(a);
52804         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52805         a_conv.is_owned = false;
52806         LDKRawDataPart b_conv;
52807         b_conv.inner = untag_ptr(b);
52808         b_conv.is_owned = ptr_is_owned(b);
52809         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52810         b_conv.is_owned = false;
52811         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
52812         return ret_conv;
52813 }
52814
52815 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
52816         LDKRawDataPart ret_var = RawDataPart_clone(arg);
52817         int64_t ret_ref = 0;
52818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52819         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52820         return ret_ref;
52821 }
52822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52823         LDKRawDataPart arg_conv;
52824         arg_conv.inner = untag_ptr(arg);
52825         arg_conv.is_owned = ptr_is_owned(arg);
52826         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52827         arg_conv.is_owned = false;
52828         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
52829         return ret_conv;
52830 }
52831
52832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52833         LDKRawDataPart orig_conv;
52834         orig_conv.inner = untag_ptr(orig);
52835         orig_conv.is_owned = ptr_is_owned(orig);
52836         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52837         orig_conv.is_owned = false;
52838         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
52839         int64_t ret_ref = 0;
52840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52841         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52842         return ret_ref;
52843 }
52844
52845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1hash(JNIEnv *env, jclass clz, int64_t o) {
52846         LDKRawDataPart o_conv;
52847         o_conv.inner = untag_ptr(o);
52848         o_conv.is_owned = ptr_is_owned(o);
52849         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52850         o_conv.is_owned = false;
52851         int64_t ret_conv = RawDataPart_hash(&o_conv);
52852         return ret_conv;
52853 }
52854
52855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52856         LDKPositiveTimestamp this_obj_conv;
52857         this_obj_conv.inner = untag_ptr(this_obj);
52858         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52860         PositiveTimestamp_free(this_obj_conv);
52861 }
52862
52863 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52864         LDKPositiveTimestamp a_conv;
52865         a_conv.inner = untag_ptr(a);
52866         a_conv.is_owned = ptr_is_owned(a);
52867         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52868         a_conv.is_owned = false;
52869         LDKPositiveTimestamp b_conv;
52870         b_conv.inner = untag_ptr(b);
52871         b_conv.is_owned = ptr_is_owned(b);
52872         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52873         b_conv.is_owned = false;
52874         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
52875         return ret_conv;
52876 }
52877
52878 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
52879         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
52880         int64_t ret_ref = 0;
52881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52882         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52883         return ret_ref;
52884 }
52885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52886         LDKPositiveTimestamp arg_conv;
52887         arg_conv.inner = untag_ptr(arg);
52888         arg_conv.is_owned = ptr_is_owned(arg);
52889         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52890         arg_conv.is_owned = false;
52891         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
52892         return ret_conv;
52893 }
52894
52895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52896         LDKPositiveTimestamp orig_conv;
52897         orig_conv.inner = untag_ptr(orig);
52898         orig_conv.is_owned = ptr_is_owned(orig);
52899         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52900         orig_conv.is_owned = false;
52901         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
52902         int64_t ret_ref = 0;
52903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52905         return ret_ref;
52906 }
52907
52908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1hash(JNIEnv *env, jclass clz, int64_t o) {
52909         LDKPositiveTimestamp o_conv;
52910         o_conv.inner = untag_ptr(o);
52911         o_conv.is_owned = ptr_is_owned(o);
52912         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52913         o_conv.is_owned = false;
52914         int64_t ret_conv = PositiveTimestamp_hash(&o_conv);
52915         return ret_conv;
52916 }
52917
52918 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52919         LDKSiPrefix* orig_conv = (LDKSiPrefix*)untag_ptr(orig);
52920         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
52921         return ret_conv;
52922 }
52923
52924 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
52925         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
52926         return ret_conv;
52927 }
52928
52929 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
52930         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
52931         return ret_conv;
52932 }
52933
52934 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
52935         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
52936         return ret_conv;
52937 }
52938
52939 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
52940         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
52941         return ret_conv;
52942 }
52943
52944 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52945         LDKSiPrefix* a_conv = (LDKSiPrefix*)untag_ptr(a);
52946         LDKSiPrefix* b_conv = (LDKSiPrefix*)untag_ptr(b);
52947         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
52948         return ret_conv;
52949 }
52950
52951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1hash(JNIEnv *env, jclass clz, int64_t o) {
52952         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
52953         int64_t ret_conv = SiPrefix_hash(o_conv);
52954         return ret_conv;
52955 }
52956
52957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
52958         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)untag_ptr(this_arg);
52959         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
52960         return ret_conv;
52961 }
52962
52963 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52964         LDKCurrency* orig_conv = (LDKCurrency*)untag_ptr(orig);
52965         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
52966         return ret_conv;
52967 }
52968
52969 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
52970         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
52971         return ret_conv;
52972 }
52973
52974 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
52975         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
52976         return ret_conv;
52977 }
52978
52979 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
52980         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
52981         return ret_conv;
52982 }
52983
52984 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
52985         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
52986         return ret_conv;
52987 }
52988
52989 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
52990         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
52991         return ret_conv;
52992 }
52993
52994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
52995         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
52996         int64_t ret_conv = Currency_hash(o_conv);
52997         return ret_conv;
52998 }
52999
53000 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53001         LDKCurrency* a_conv = (LDKCurrency*)untag_ptr(a);
53002         LDKCurrency* b_conv = (LDKCurrency*)untag_ptr(b);
53003         jboolean ret_conv = Currency_eq(a_conv, b_conv);
53004         return ret_conv;
53005 }
53006
53007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53008         LDKSha256 this_obj_conv;
53009         this_obj_conv.inner = untag_ptr(this_obj);
53010         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53012         Sha256_free(this_obj_conv);
53013 }
53014
53015 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
53016         LDKSha256 ret_var = Sha256_clone(arg);
53017         int64_t ret_ref = 0;
53018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53019         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53020         return ret_ref;
53021 }
53022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53023         LDKSha256 arg_conv;
53024         arg_conv.inner = untag_ptr(arg);
53025         arg_conv.is_owned = ptr_is_owned(arg);
53026         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53027         arg_conv.is_owned = false;
53028         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
53029         return ret_conv;
53030 }
53031
53032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53033         LDKSha256 orig_conv;
53034         orig_conv.inner = untag_ptr(orig);
53035         orig_conv.is_owned = ptr_is_owned(orig);
53036         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53037         orig_conv.is_owned = false;
53038         LDKSha256 ret_var = Sha256_clone(&orig_conv);
53039         int64_t ret_ref = 0;
53040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53041         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53042         return ret_ref;
53043 }
53044
53045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
53046         LDKSha256 o_conv;
53047         o_conv.inner = untag_ptr(o);
53048         o_conv.is_owned = ptr_is_owned(o);
53049         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53050         o_conv.is_owned = false;
53051         int64_t ret_conv = Sha256_hash(&o_conv);
53052         return ret_conv;
53053 }
53054
53055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53056         LDKSha256 a_conv;
53057         a_conv.inner = untag_ptr(a);
53058         a_conv.is_owned = ptr_is_owned(a);
53059         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53060         a_conv.is_owned = false;
53061         LDKSha256 b_conv;
53062         b_conv.inner = untag_ptr(b);
53063         b_conv.is_owned = ptr_is_owned(b);
53064         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53065         b_conv.is_owned = false;
53066         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
53067         return ret_conv;
53068 }
53069
53070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53071         LDKDescription this_obj_conv;
53072         this_obj_conv.inner = untag_ptr(this_obj);
53073         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53075         Description_free(this_obj_conv);
53076 }
53077
53078 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
53079         LDKDescription ret_var = Description_clone(arg);
53080         int64_t ret_ref = 0;
53081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53082         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53083         return ret_ref;
53084 }
53085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53086         LDKDescription arg_conv;
53087         arg_conv.inner = untag_ptr(arg);
53088         arg_conv.is_owned = ptr_is_owned(arg);
53089         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53090         arg_conv.is_owned = false;
53091         int64_t ret_conv = Description_clone_ptr(&arg_conv);
53092         return ret_conv;
53093 }
53094
53095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53096         LDKDescription orig_conv;
53097         orig_conv.inner = untag_ptr(orig);
53098         orig_conv.is_owned = ptr_is_owned(orig);
53099         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53100         orig_conv.is_owned = false;
53101         LDKDescription ret_var = Description_clone(&orig_conv);
53102         int64_t ret_ref = 0;
53103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53104         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53105         return ret_ref;
53106 }
53107
53108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
53109         LDKDescription o_conv;
53110         o_conv.inner = untag_ptr(o);
53111         o_conv.is_owned = ptr_is_owned(o);
53112         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53113         o_conv.is_owned = false;
53114         int64_t ret_conv = Description_hash(&o_conv);
53115         return ret_conv;
53116 }
53117
53118 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53119         LDKDescription a_conv;
53120         a_conv.inner = untag_ptr(a);
53121         a_conv.is_owned = ptr_is_owned(a);
53122         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53123         a_conv.is_owned = false;
53124         LDKDescription b_conv;
53125         b_conv.inner = untag_ptr(b);
53126         b_conv.is_owned = ptr_is_owned(b);
53127         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53128         b_conv.is_owned = false;
53129         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
53130         return ret_conv;
53131 }
53132
53133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53134         LDKPayeePubKey this_obj_conv;
53135         this_obj_conv.inner = untag_ptr(this_obj);
53136         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53138         PayeePubKey_free(this_obj_conv);
53139 }
53140
53141 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
53142         LDKPayeePubKey this_ptr_conv;
53143         this_ptr_conv.inner = untag_ptr(this_ptr);
53144         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53146         this_ptr_conv.is_owned = false;
53147         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
53148         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
53149         return ret_arr;
53150 }
53151
53152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
53153         LDKPayeePubKey this_ptr_conv;
53154         this_ptr_conv.inner = untag_ptr(this_ptr);
53155         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53157         this_ptr_conv.is_owned = false;
53158         LDKPublicKey val_ref;
53159         CHECK((*env)->GetArrayLength(env, val) == 33);
53160         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
53161         PayeePubKey_set_a(&this_ptr_conv, val_ref);
53162 }
53163
53164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
53165         LDKPublicKey a_arg_ref;
53166         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
53167         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
53168         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
53169         int64_t ret_ref = 0;
53170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53171         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53172         return ret_ref;
53173 }
53174
53175 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
53176         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
53177         int64_t ret_ref = 0;
53178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53179         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53180         return ret_ref;
53181 }
53182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53183         LDKPayeePubKey arg_conv;
53184         arg_conv.inner = untag_ptr(arg);
53185         arg_conv.is_owned = ptr_is_owned(arg);
53186         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53187         arg_conv.is_owned = false;
53188         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
53189         return ret_conv;
53190 }
53191
53192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53193         LDKPayeePubKey orig_conv;
53194         orig_conv.inner = untag_ptr(orig);
53195         orig_conv.is_owned = ptr_is_owned(orig);
53196         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53197         orig_conv.is_owned = false;
53198         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
53199         int64_t ret_ref = 0;
53200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53201         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53202         return ret_ref;
53203 }
53204
53205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
53206         LDKPayeePubKey o_conv;
53207         o_conv.inner = untag_ptr(o);
53208         o_conv.is_owned = ptr_is_owned(o);
53209         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53210         o_conv.is_owned = false;
53211         int64_t ret_conv = PayeePubKey_hash(&o_conv);
53212         return ret_conv;
53213 }
53214
53215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53216         LDKPayeePubKey a_conv;
53217         a_conv.inner = untag_ptr(a);
53218         a_conv.is_owned = ptr_is_owned(a);
53219         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53220         a_conv.is_owned = false;
53221         LDKPayeePubKey b_conv;
53222         b_conv.inner = untag_ptr(b);
53223         b_conv.is_owned = ptr_is_owned(b);
53224         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53225         b_conv.is_owned = false;
53226         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
53227         return ret_conv;
53228 }
53229
53230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53231         LDKExpiryTime this_obj_conv;
53232         this_obj_conv.inner = untag_ptr(this_obj);
53233         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53235         ExpiryTime_free(this_obj_conv);
53236 }
53237
53238 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
53239         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
53240         int64_t ret_ref = 0;
53241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53242         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53243         return ret_ref;
53244 }
53245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53246         LDKExpiryTime arg_conv;
53247         arg_conv.inner = untag_ptr(arg);
53248         arg_conv.is_owned = ptr_is_owned(arg);
53249         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53250         arg_conv.is_owned = false;
53251         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
53252         return ret_conv;
53253 }
53254
53255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53256         LDKExpiryTime orig_conv;
53257         orig_conv.inner = untag_ptr(orig);
53258         orig_conv.is_owned = ptr_is_owned(orig);
53259         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53260         orig_conv.is_owned = false;
53261         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
53262         int64_t ret_ref = 0;
53263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53264         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53265         return ret_ref;
53266 }
53267
53268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
53269         LDKExpiryTime o_conv;
53270         o_conv.inner = untag_ptr(o);
53271         o_conv.is_owned = ptr_is_owned(o);
53272         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53273         o_conv.is_owned = false;
53274         int64_t ret_conv = ExpiryTime_hash(&o_conv);
53275         return ret_conv;
53276 }
53277
53278 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53279         LDKExpiryTime a_conv;
53280         a_conv.inner = untag_ptr(a);
53281         a_conv.is_owned = ptr_is_owned(a);
53282         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53283         a_conv.is_owned = false;
53284         LDKExpiryTime b_conv;
53285         b_conv.inner = untag_ptr(b);
53286         b_conv.is_owned = ptr_is_owned(b);
53287         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53288         b_conv.is_owned = false;
53289         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
53290         return ret_conv;
53291 }
53292
53293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53294         LDKMinFinalCltvExpiryDelta this_obj_conv;
53295         this_obj_conv.inner = untag_ptr(this_obj);
53296         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53298         MinFinalCltvExpiryDelta_free(this_obj_conv);
53299 }
53300
53301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
53302         LDKMinFinalCltvExpiryDelta this_ptr_conv;
53303         this_ptr_conv.inner = untag_ptr(this_ptr);
53304         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53306         this_ptr_conv.is_owned = false;
53307         int64_t ret_conv = MinFinalCltvExpiryDelta_get_a(&this_ptr_conv);
53308         return ret_conv;
53309 }
53310
53311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
53312         LDKMinFinalCltvExpiryDelta this_ptr_conv;
53313         this_ptr_conv.inner = untag_ptr(this_ptr);
53314         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53316         this_ptr_conv.is_owned = false;
53317         MinFinalCltvExpiryDelta_set_a(&this_ptr_conv, val);
53318 }
53319
53320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
53321         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_new(a_arg);
53322         int64_t ret_ref = 0;
53323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53324         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53325         return ret_ref;
53326 }
53327
53328 static inline uint64_t MinFinalCltvExpiryDelta_clone_ptr(LDKMinFinalCltvExpiryDelta *NONNULL_PTR arg) {
53329         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_clone(arg);
53330         int64_t ret_ref = 0;
53331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53332         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53333         return ret_ref;
53334 }
53335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53336         LDKMinFinalCltvExpiryDelta arg_conv;
53337         arg_conv.inner = untag_ptr(arg);
53338         arg_conv.is_owned = ptr_is_owned(arg);
53339         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53340         arg_conv.is_owned = false;
53341         int64_t ret_conv = MinFinalCltvExpiryDelta_clone_ptr(&arg_conv);
53342         return ret_conv;
53343 }
53344
53345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53346         LDKMinFinalCltvExpiryDelta orig_conv;
53347         orig_conv.inner = untag_ptr(orig);
53348         orig_conv.is_owned = ptr_is_owned(orig);
53349         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53350         orig_conv.is_owned = false;
53351         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_clone(&orig_conv);
53352         int64_t ret_ref = 0;
53353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53354         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53355         return ret_ref;
53356 }
53357
53358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1hash(JNIEnv *env, jclass clz, int64_t o) {
53359         LDKMinFinalCltvExpiryDelta o_conv;
53360         o_conv.inner = untag_ptr(o);
53361         o_conv.is_owned = ptr_is_owned(o);
53362         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53363         o_conv.is_owned = false;
53364         int64_t ret_conv = MinFinalCltvExpiryDelta_hash(&o_conv);
53365         return ret_conv;
53366 }
53367
53368 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53369         LDKMinFinalCltvExpiryDelta a_conv;
53370         a_conv.inner = untag_ptr(a);
53371         a_conv.is_owned = ptr_is_owned(a);
53372         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53373         a_conv.is_owned = false;
53374         LDKMinFinalCltvExpiryDelta b_conv;
53375         b_conv.inner = untag_ptr(b);
53376         b_conv.is_owned = ptr_is_owned(b);
53377         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53378         b_conv.is_owned = false;
53379         jboolean ret_conv = MinFinalCltvExpiryDelta_eq(&a_conv, &b_conv);
53380         return ret_conv;
53381 }
53382
53383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53384         if (!ptr_is_owned(this_ptr)) return;
53385         void* this_ptr_ptr = untag_ptr(this_ptr);
53386         CHECK_ACCESS(this_ptr_ptr);
53387         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
53388         FREE(untag_ptr(this_ptr));
53389         Fallback_free(this_ptr_conv);
53390 }
53391
53392 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
53393         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
53394         *ret_copy = Fallback_clone(arg);
53395         int64_t ret_ref = tag_ptr(ret_copy, true);
53396         return ret_ref;
53397 }
53398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53399         LDKFallback* arg_conv = (LDKFallback*)untag_ptr(arg);
53400         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
53401         return ret_conv;
53402 }
53403
53404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53405         LDKFallback* orig_conv = (LDKFallback*)untag_ptr(orig);
53406         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
53407         *ret_copy = Fallback_clone(orig_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_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
53413         
53414         LDKCVec_u8Z program_ref;
53415         program_ref.datalen = (*env)->GetArrayLength(env, program);
53416         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
53417         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
53418         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
53419         *ret_copy = Fallback_seg_wit_program((LDKU5){ ._0 = version }, program_ref);
53420         int64_t ret_ref = tag_ptr(ret_copy, true);
53421         return ret_ref;
53422 }
53423
53424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
53425         LDKTwentyBytes a_ref;
53426         CHECK((*env)->GetArrayLength(env, a) == 20);
53427         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
53428         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
53429         *ret_copy = Fallback_pub_key_hash(a_ref);
53430         int64_t ret_ref = tag_ptr(ret_copy, true);
53431         return ret_ref;
53432 }
53433
53434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
53435         LDKTwentyBytes a_ref;
53436         CHECK((*env)->GetArrayLength(env, a) == 20);
53437         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
53438         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
53439         *ret_copy = Fallback_script_hash(a_ref);
53440         int64_t ret_ref = tag_ptr(ret_copy, true);
53441         return ret_ref;
53442 }
53443
53444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
53445         LDKFallback* o_conv = (LDKFallback*)untag_ptr(o);
53446         int64_t ret_conv = Fallback_hash(o_conv);
53447         return ret_conv;
53448 }
53449
53450 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53451         LDKFallback* a_conv = (LDKFallback*)untag_ptr(a);
53452         LDKFallback* b_conv = (LDKFallback*)untag_ptr(b);
53453         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
53454         return ret_conv;
53455 }
53456
53457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53458         LDKInvoiceSignature this_obj_conv;
53459         this_obj_conv.inner = untag_ptr(this_obj);
53460         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53462         InvoiceSignature_free(this_obj_conv);
53463 }
53464
53465 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
53466         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
53467         int64_t ret_ref = 0;
53468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53469         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53470         return ret_ref;
53471 }
53472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53473         LDKInvoiceSignature arg_conv;
53474         arg_conv.inner = untag_ptr(arg);
53475         arg_conv.is_owned = ptr_is_owned(arg);
53476         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53477         arg_conv.is_owned = false;
53478         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
53479         return ret_conv;
53480 }
53481
53482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53483         LDKInvoiceSignature orig_conv;
53484         orig_conv.inner = untag_ptr(orig);
53485         orig_conv.is_owned = ptr_is_owned(orig);
53486         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53487         orig_conv.is_owned = false;
53488         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
53489         int64_t ret_ref = 0;
53490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53491         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53492         return ret_ref;
53493 }
53494
53495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1hash(JNIEnv *env, jclass clz, int64_t o) {
53496         LDKInvoiceSignature o_conv;
53497         o_conv.inner = untag_ptr(o);
53498         o_conv.is_owned = ptr_is_owned(o);
53499         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53500         o_conv.is_owned = false;
53501         int64_t ret_conv = InvoiceSignature_hash(&o_conv);
53502         return ret_conv;
53503 }
53504
53505 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53506         LDKInvoiceSignature a_conv;
53507         a_conv.inner = untag_ptr(a);
53508         a_conv.is_owned = ptr_is_owned(a);
53509         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53510         a_conv.is_owned = false;
53511         LDKInvoiceSignature b_conv;
53512         b_conv.inner = untag_ptr(b);
53513         b_conv.is_owned = ptr_is_owned(b);
53514         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53515         b_conv.is_owned = false;
53516         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
53517         return ret_conv;
53518 }
53519
53520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53521         LDKPrivateRoute this_obj_conv;
53522         this_obj_conv.inner = untag_ptr(this_obj);
53523         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53525         PrivateRoute_free(this_obj_conv);
53526 }
53527
53528 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
53529         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
53530         int64_t ret_ref = 0;
53531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53532         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53533         return ret_ref;
53534 }
53535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53536         LDKPrivateRoute arg_conv;
53537         arg_conv.inner = untag_ptr(arg);
53538         arg_conv.is_owned = ptr_is_owned(arg);
53539         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53540         arg_conv.is_owned = false;
53541         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
53542         return ret_conv;
53543 }
53544
53545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53546         LDKPrivateRoute orig_conv;
53547         orig_conv.inner = untag_ptr(orig);
53548         orig_conv.is_owned = ptr_is_owned(orig);
53549         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53550         orig_conv.is_owned = false;
53551         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
53552         int64_t ret_ref = 0;
53553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53554         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53555         return ret_ref;
53556 }
53557
53558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
53559         LDKPrivateRoute o_conv;
53560         o_conv.inner = untag_ptr(o);
53561         o_conv.is_owned = ptr_is_owned(o);
53562         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53563         o_conv.is_owned = false;
53564         int64_t ret_conv = PrivateRoute_hash(&o_conv);
53565         return ret_conv;
53566 }
53567
53568 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53569         LDKPrivateRoute a_conv;
53570         a_conv.inner = untag_ptr(a);
53571         a_conv.is_owned = ptr_is_owned(a);
53572         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53573         a_conv.is_owned = false;
53574         LDKPrivateRoute b_conv;
53575         b_conv.inner = untag_ptr(b);
53576         b_conv.is_owned = ptr_is_owned(b);
53577         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53578         b_conv.is_owned = false;
53579         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
53580         return ret_conv;
53581 }
53582
53583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
53584         LDKSignedRawInvoice this_arg_conv;
53585         this_arg_conv.inner = untag_ptr(this_arg);
53586         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53588         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
53589         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
53590         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
53591         return tag_ptr(ret_conv, true);
53592 }
53593
53594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
53595         LDKSignedRawInvoice this_arg_conv;
53596         this_arg_conv.inner = untag_ptr(this_arg);
53597         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53599         this_arg_conv.is_owned = false;
53600         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
53601         int64_t ret_ref = 0;
53602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53603         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53604         return ret_ref;
53605 }
53606
53607 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
53608         LDKSignedRawInvoice this_arg_conv;
53609         this_arg_conv.inner = untag_ptr(this_arg);
53610         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53612         this_arg_conv.is_owned = false;
53613         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
53614         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_signable_hash(&this_arg_conv));
53615         return ret_arr;
53616 }
53617
53618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
53619         LDKSignedRawInvoice this_arg_conv;
53620         this_arg_conv.inner = untag_ptr(this_arg);
53621         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53623         this_arg_conv.is_owned = false;
53624         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
53625         int64_t ret_ref = 0;
53626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53627         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53628         return ret_ref;
53629 }
53630
53631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
53632         LDKSignedRawInvoice this_arg_conv;
53633         this_arg_conv.inner = untag_ptr(this_arg);
53634         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53636         this_arg_conv.is_owned = false;
53637         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
53638         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
53639         return tag_ptr(ret_conv, true);
53640 }
53641
53642 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
53643         LDKSignedRawInvoice this_arg_conv;
53644         this_arg_conv.inner = untag_ptr(this_arg);
53645         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53647         this_arg_conv.is_owned = false;
53648         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
53649         return ret_conv;
53650 }
53651
53652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
53653         LDKRawInvoice this_arg_conv;
53654         this_arg_conv.inner = untag_ptr(this_arg);
53655         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53657         this_arg_conv.is_owned = false;
53658         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
53659         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_signable_hash(&this_arg_conv).data);
53660         return ret_arr;
53661 }
53662
53663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
53664         LDKRawInvoice this_arg_conv;
53665         this_arg_conv.inner = untag_ptr(this_arg);
53666         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53668         this_arg_conv.is_owned = false;
53669         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
53670         int64_t ret_ref = 0;
53671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53672         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53673         return ret_ref;
53674 }
53675
53676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
53677         LDKRawInvoice this_arg_conv;
53678         this_arg_conv.inner = untag_ptr(this_arg);
53679         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53681         this_arg_conv.is_owned = false;
53682         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
53683         int64_t ret_ref = 0;
53684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53685         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53686         return ret_ref;
53687 }
53688
53689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
53690         LDKRawInvoice this_arg_conv;
53691         this_arg_conv.inner = untag_ptr(this_arg);
53692         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53694         this_arg_conv.is_owned = false;
53695         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
53696         int64_t ret_ref = 0;
53697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53698         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53699         return ret_ref;
53700 }
53701
53702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
53703         LDKRawInvoice this_arg_conv;
53704         this_arg_conv.inner = untag_ptr(this_arg);
53705         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53707         this_arg_conv.is_owned = false;
53708         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
53709         int64_t ret_ref = 0;
53710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53711         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53712         return ret_ref;
53713 }
53714
53715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
53716         LDKRawInvoice this_arg_conv;
53717         this_arg_conv.inner = untag_ptr(this_arg);
53718         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53720         this_arg_conv.is_owned = false;
53721         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
53722         int64_t ret_ref = 0;
53723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53724         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53725         return ret_ref;
53726 }
53727
53728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_arg) {
53729         LDKRawInvoice this_arg_conv;
53730         this_arg_conv.inner = untag_ptr(this_arg);
53731         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53733         this_arg_conv.is_owned = false;
53734         LDKMinFinalCltvExpiryDelta ret_var = RawInvoice_min_final_cltv_expiry_delta(&this_arg_conv);
53735         int64_t ret_ref = 0;
53736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53737         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53738         return ret_ref;
53739 }
53740
53741 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
53742         LDKRawInvoice this_arg_conv;
53743         this_arg_conv.inner = untag_ptr(this_arg);
53744         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53746         this_arg_conv.is_owned = false;
53747         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
53748         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
53749         return ret_arr;
53750 }
53751
53752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
53753         LDKRawInvoice this_arg_conv;
53754         this_arg_conv.inner = untag_ptr(this_arg);
53755         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53757         this_arg_conv.is_owned = false;
53758         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
53759         int64_t ret_ref = 0;
53760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53762         return ret_ref;
53763 }
53764
53765 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
53766         LDKRawInvoice this_arg_conv;
53767         this_arg_conv.inner = untag_ptr(this_arg);
53768         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53770         this_arg_conv.is_owned = false;
53771         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
53772         int64_tArray ret_arr = NULL;
53773         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
53774         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
53775         for (size_t o = 0; o < ret_var.datalen; o++) {
53776                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
53777                 int64_t ret_conv_14_ref = 0;
53778                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
53779                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
53780                 ret_arr_ptr[o] = ret_conv_14_ref;
53781         }
53782         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
53783         FREE(ret_var.data);
53784         return ret_arr;
53785 }
53786
53787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
53788         LDKRawInvoice this_arg_conv;
53789         this_arg_conv.inner = untag_ptr(this_arg);
53790         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53792         this_arg_conv.is_owned = false;
53793         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
53794         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
53795         int64_t ret_ref = tag_ptr(ret_copy, true);
53796         return ret_ref;
53797 }
53798
53799 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
53800         LDKRawInvoice this_arg_conv;
53801         this_arg_conv.inner = untag_ptr(this_arg);
53802         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53804         this_arg_conv.is_owned = false;
53805         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
53806         return ret_conv;
53807 }
53808
53809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
53810         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
53811         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
53812         return tag_ptr(ret_conv, true);
53813 }
53814
53815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
53816         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
53817         *ret_conv = PositiveTimestamp_from_system_time(time);
53818         return tag_ptr(ret_conv, true);
53819 }
53820
53821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
53822         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
53823         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
53824         return tag_ptr(ret_conv, true);
53825 }
53826
53827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
53828         LDKPositiveTimestamp this_arg_conv;
53829         this_arg_conv.inner = untag_ptr(this_arg);
53830         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53832         this_arg_conv.is_owned = false;
53833         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
53834         return ret_conv;
53835 }
53836
53837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
53838         LDKPositiveTimestamp this_arg_conv;
53839         this_arg_conv.inner = untag_ptr(this_arg);
53840         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53842         this_arg_conv.is_owned = false;
53843         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
53844         return ret_conv;
53845 }
53846
53847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
53848         LDKPositiveTimestamp this_arg_conv;
53849         this_arg_conv.inner = untag_ptr(this_arg);
53850         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53852         this_arg_conv.is_owned = false;
53853         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
53854         return ret_conv;
53855 }
53856
53857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
53858         LDKInvoice this_arg_conv;
53859         this_arg_conv.inner = untag_ptr(this_arg);
53860         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53862         this_arg_conv = Invoice_clone(&this_arg_conv);
53863         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
53864         int64_t ret_ref = 0;
53865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53866         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53867         return ret_ref;
53868 }
53869
53870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
53871         LDKInvoice this_arg_conv;
53872         this_arg_conv.inner = untag_ptr(this_arg);
53873         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53875         this_arg_conv.is_owned = false;
53876         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
53877         *ret_conv = Invoice_check_signature(&this_arg_conv);
53878         return tag_ptr(ret_conv, true);
53879 }
53880
53881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
53882         LDKSignedRawInvoice signed_invoice_conv;
53883         signed_invoice_conv.inner = untag_ptr(signed_invoice);
53884         signed_invoice_conv.is_owned = ptr_is_owned(signed_invoice);
53885         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
53886         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
53887         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
53888         *ret_conv = Invoice_from_signed(signed_invoice_conv);
53889         return tag_ptr(ret_conv, true);
53890 }
53891
53892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
53893         LDKInvoice this_arg_conv;
53894         this_arg_conv.inner = untag_ptr(this_arg);
53895         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53897         this_arg_conv.is_owned = false;
53898         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
53899         return ret_conv;
53900 }
53901
53902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
53903         LDKInvoice this_arg_conv;
53904         this_arg_conv.inner = untag_ptr(this_arg);
53905         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53907         this_arg_conv.is_owned = false;
53908         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
53909         return ret_conv;
53910 }
53911
53912 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
53913         LDKInvoice this_arg_conv;
53914         this_arg_conv.inner = untag_ptr(this_arg);
53915         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53917         this_arg_conv.is_owned = false;
53918         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
53919         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
53920         return ret_arr;
53921 }
53922
53923 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
53924         LDKInvoice this_arg_conv;
53925         this_arg_conv.inner = untag_ptr(this_arg);
53926         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53928         this_arg_conv.is_owned = false;
53929         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
53930         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
53931         return ret_arr;
53932 }
53933
53934 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
53935         LDKInvoice this_arg_conv;
53936         this_arg_conv.inner = untag_ptr(this_arg);
53937         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53939         this_arg_conv.is_owned = false;
53940         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
53941         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
53942         return ret_arr;
53943 }
53944
53945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
53946         LDKInvoice this_arg_conv;
53947         this_arg_conv.inner = untag_ptr(this_arg);
53948         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53950         this_arg_conv.is_owned = false;
53951         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
53952         int64_t ret_ref = 0;
53953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53954         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53955         return ret_ref;
53956 }
53957
53958 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
53959         LDKInvoice this_arg_conv;
53960         this_arg_conv.inner = untag_ptr(this_arg);
53961         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53963         this_arg_conv.is_owned = false;
53964         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
53965         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
53966         return ret_arr;
53967 }
53968
53969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
53970         LDKInvoice this_arg_conv;
53971         this_arg_conv.inner = untag_ptr(this_arg);
53972         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53974         this_arg_conv.is_owned = false;
53975         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
53976         return ret_conv;
53977 }
53978
53979 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
53980         LDKInvoice this_arg_conv;
53981         this_arg_conv.inner = untag_ptr(this_arg);
53982         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53984         this_arg_conv.is_owned = false;
53985         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
53986         return ret_conv;
53987 }
53988
53989 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
53990         LDKInvoice this_arg_conv;
53991         this_arg_conv.inner = untag_ptr(this_arg);
53992         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53994         this_arg_conv.is_owned = false;
53995         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
53996         return ret_conv;
53997 }
53998
53999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_arg) {
54000         LDKInvoice this_arg_conv;
54001         this_arg_conv.inner = untag_ptr(this_arg);
54002         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54004         this_arg_conv.is_owned = false;
54005         int64_t ret_conv = Invoice_min_final_cltv_expiry_delta(&this_arg_conv);
54006         return ret_conv;
54007 }
54008
54009 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
54010         LDKInvoice this_arg_conv;
54011         this_arg_conv.inner = untag_ptr(this_arg);
54012         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54014         this_arg_conv.is_owned = false;
54015         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
54016         int64_tArray ret_arr = NULL;
54017         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
54018         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
54019         for (size_t o = 0; o < ret_var.datalen; o++) {
54020                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
54021                 int64_t ret_conv_14_ref = 0;
54022                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
54023                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
54024                 ret_arr_ptr[o] = ret_conv_14_ref;
54025         }
54026         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
54027         FREE(ret_var.data);
54028         return ret_arr;
54029 }
54030
54031 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
54032         LDKInvoice this_arg_conv;
54033         this_arg_conv.inner = untag_ptr(this_arg);
54034         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54036         this_arg_conv.is_owned = false;
54037         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
54038         int64_tArray ret_arr = NULL;
54039         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
54040         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
54041         for (size_t l = 0; l < ret_var.datalen; l++) {
54042                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
54043                 int64_t ret_conv_11_ref = 0;
54044                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
54045                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
54046                 ret_arr_ptr[l] = ret_conv_11_ref;
54047         }
54048         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
54049         FREE(ret_var.data);
54050         return ret_arr;
54051 }
54052
54053 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
54054         LDKInvoice this_arg_conv;
54055         this_arg_conv.inner = untag_ptr(this_arg);
54056         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54058         this_arg_conv.is_owned = false;
54059         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
54060         return ret_conv;
54061 }
54062
54063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
54064         LDKInvoice this_arg_conv;
54065         this_arg_conv.inner = untag_ptr(this_arg);
54066         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54068         this_arg_conv.is_owned = false;
54069         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
54070         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
54071         int64_t ret_ref = tag_ptr(ret_copy, true);
54072         return ret_ref;
54073 }
54074
54075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
54076         LDKStr description_conv = java_to_owned_str(env, description);
54077         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
54078         *ret_conv = Description_new(description_conv);
54079         return tag_ptr(ret_conv, true);
54080 }
54081
54082 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
54083         LDKDescription this_arg_conv;
54084         this_arg_conv.inner = untag_ptr(this_arg);
54085         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54087         this_arg_conv = Description_clone(&this_arg_conv);
54088         LDKStr ret_str = Description_into_inner(this_arg_conv);
54089         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
54090         Str_free(ret_str);
54091         return ret_conv;
54092 }
54093
54094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
54095         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
54096         int64_t ret_ref = 0;
54097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54098         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54099         return ret_ref;
54100 }
54101
54102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
54103         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
54104         int64_t ret_ref = 0;
54105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54106         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54107         return ret_ref;
54108 }
54109
54110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
54111         LDKExpiryTime this_arg_conv;
54112         this_arg_conv.inner = untag_ptr(this_arg);
54113         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54115         this_arg_conv.is_owned = false;
54116         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
54117         return ret_conv;
54118 }
54119
54120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
54121         LDKExpiryTime this_arg_conv;
54122         this_arg_conv.inner = untag_ptr(this_arg);
54123         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54125         this_arg_conv.is_owned = false;
54126         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
54127         return ret_conv;
54128 }
54129
54130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
54131         LDKRouteHint hops_conv;
54132         hops_conv.inner = untag_ptr(hops);
54133         hops_conv.is_owned = ptr_is_owned(hops);
54134         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
54135         hops_conv = RouteHint_clone(&hops_conv);
54136         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
54137         *ret_conv = PrivateRoute_new(hops_conv);
54138         return tag_ptr(ret_conv, true);
54139 }
54140
54141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
54142         LDKPrivateRoute this_arg_conv;
54143         this_arg_conv.inner = untag_ptr(this_arg);
54144         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54146         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
54147         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
54148         int64_t ret_ref = 0;
54149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54150         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54151         return ret_ref;
54152 }
54153
54154 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54155         LDKCreationError* orig_conv = (LDKCreationError*)untag_ptr(orig);
54156         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
54157         return ret_conv;
54158 }
54159
54160 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
54161         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
54162         return ret_conv;
54163 }
54164
54165 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
54166         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
54167         return ret_conv;
54168 }
54169
54170 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
54171         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
54172         return ret_conv;
54173 }
54174
54175 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
54176         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
54177         return ret_conv;
54178 }
54179
54180 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
54181         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
54182         return ret_conv;
54183 }
54184
54185 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1min_1final_1cltv_1expiry_1delta_1too_1short(JNIEnv *env, jclass clz) {
54186         jclass ret_conv = LDKCreationError_to_java(env, CreationError_min_final_cltv_expiry_delta_too_short());
54187         return ret_conv;
54188 }
54189
54190 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54191         LDKCreationError* a_conv = (LDKCreationError*)untag_ptr(a);
54192         LDKCreationError* b_conv = (LDKCreationError*)untag_ptr(b);
54193         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
54194         return ret_conv;
54195 }
54196
54197 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
54198         LDKCreationError* o_conv = (LDKCreationError*)untag_ptr(o);
54199         LDKStr ret_str = CreationError_to_str(o_conv);
54200         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
54201         Str_free(ret_str);
54202         return ret_conv;
54203 }
54204
54205 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54206         LDKSemanticError* orig_conv = (LDKSemanticError*)untag_ptr(orig);
54207         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
54208         return ret_conv;
54209 }
54210
54211 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
54212         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
54213         return ret_conv;
54214 }
54215
54216 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
54217         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
54218         return ret_conv;
54219 }
54220
54221 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
54222         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
54223         return ret_conv;
54224 }
54225
54226 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
54227         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
54228         return ret_conv;
54229 }
54230
54231 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
54232         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
54233         return ret_conv;
54234 }
54235
54236 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
54237         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
54238         return ret_conv;
54239 }
54240
54241 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
54242         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
54243         return ret_conv;
54244 }
54245
54246 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
54247         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
54248         return ret_conv;
54249 }
54250
54251 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
54252         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
54253         return ret_conv;
54254 }
54255
54256 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
54257         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
54258         return ret_conv;
54259 }
54260
54261 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54262         LDKSemanticError* a_conv = (LDKSemanticError*)untag_ptr(a);
54263         LDKSemanticError* b_conv = (LDKSemanticError*)untag_ptr(b);
54264         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
54265         return ret_conv;
54266 }
54267
54268 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
54269         LDKSemanticError* o_conv = (LDKSemanticError*)untag_ptr(o);
54270         LDKStr ret_str = SemanticError_to_str(o_conv);
54271         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
54272         Str_free(ret_str);
54273         return ret_conv;
54274 }
54275
54276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54277         if (!ptr_is_owned(this_ptr)) return;
54278         void* this_ptr_ptr = untag_ptr(this_ptr);
54279         CHECK_ACCESS(this_ptr_ptr);
54280         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
54281         FREE(untag_ptr(this_ptr));
54282         SignOrCreationError_free(this_ptr_conv);
54283 }
54284
54285 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
54286         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
54287         *ret_copy = SignOrCreationError_clone(arg);
54288         int64_t ret_ref = tag_ptr(ret_copy, true);
54289         return ret_ref;
54290 }
54291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54292         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)untag_ptr(arg);
54293         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
54294         return ret_conv;
54295 }
54296
54297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54298         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)untag_ptr(orig);
54299         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
54300         *ret_copy = SignOrCreationError_clone(orig_conv);
54301         int64_t ret_ref = tag_ptr(ret_copy, true);
54302         return ret_ref;
54303 }
54304
54305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
54306         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
54307         *ret_copy = SignOrCreationError_sign_error();
54308         int64_t ret_ref = tag_ptr(ret_copy, true);
54309         return ret_ref;
54310 }
54311
54312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
54313         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
54314         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
54315         *ret_copy = SignOrCreationError_creation_error(a_conv);
54316         int64_t ret_ref = tag_ptr(ret_copy, true);
54317         return ret_ref;
54318 }
54319
54320 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54321         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)untag_ptr(a);
54322         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)untag_ptr(b);
54323         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
54324         return ret_conv;
54325 }
54326
54327 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
54328         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)untag_ptr(o);
54329         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
54330         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
54331         Str_free(ret_str);
54332         return ret_conv;
54333 }
54334
54335 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) {
54336         LDKInvoice invoice_conv;
54337         invoice_conv.inner = untag_ptr(invoice);
54338         invoice_conv.is_owned = ptr_is_owned(invoice);
54339         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
54340         invoice_conv.is_owned = false;
54341         void* retry_strategy_ptr = untag_ptr(retry_strategy);
54342         CHECK_ACCESS(retry_strategy_ptr);
54343         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
54344         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
54345         LDKChannelManager channelmanager_conv;
54346         channelmanager_conv.inner = untag_ptr(channelmanager);
54347         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
54348         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
54349         channelmanager_conv.is_owned = false;
54350         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
54351         *ret_conv = pay_invoice(&invoice_conv, retry_strategy_conv, &channelmanager_conv);
54352         return tag_ptr(ret_conv, true);
54353 }
54354
54355 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) {
54356         LDKInvoice invoice_conv;
54357         invoice_conv.inner = untag_ptr(invoice);
54358         invoice_conv.is_owned = ptr_is_owned(invoice);
54359         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
54360         invoice_conv.is_owned = false;
54361         LDKThirtyTwoBytes payment_id_ref;
54362         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54363         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54364         void* retry_strategy_ptr = untag_ptr(retry_strategy);
54365         CHECK_ACCESS(retry_strategy_ptr);
54366         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
54367         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
54368         LDKChannelManager channelmanager_conv;
54369         channelmanager_conv.inner = untag_ptr(channelmanager);
54370         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
54371         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
54372         channelmanager_conv.is_owned = false;
54373         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
54374         *ret_conv = pay_invoice_with_id(&invoice_conv, payment_id_ref, retry_strategy_conv, &channelmanager_conv);
54375         return tag_ptr(ret_conv, true);
54376 }
54377
54378 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) {
54379         LDKInvoice invoice_conv;
54380         invoice_conv.inner = untag_ptr(invoice);
54381         invoice_conv.is_owned = ptr_is_owned(invoice);
54382         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
54383         invoice_conv.is_owned = false;
54384         void* retry_strategy_ptr = untag_ptr(retry_strategy);
54385         CHECK_ACCESS(retry_strategy_ptr);
54386         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
54387         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
54388         LDKChannelManager channelmanager_conv;
54389         channelmanager_conv.inner = untag_ptr(channelmanager);
54390         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
54391         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
54392         channelmanager_conv.is_owned = false;
54393         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
54394         *ret_conv = pay_zero_value_invoice(&invoice_conv, amount_msats, retry_strategy_conv, &channelmanager_conv);
54395         return tag_ptr(ret_conv, true);
54396 }
54397
54398 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) {
54399         LDKInvoice invoice_conv;
54400         invoice_conv.inner = untag_ptr(invoice);
54401         invoice_conv.is_owned = ptr_is_owned(invoice);
54402         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
54403         invoice_conv.is_owned = false;
54404         LDKThirtyTwoBytes payment_id_ref;
54405         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54406         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54407         void* retry_strategy_ptr = untag_ptr(retry_strategy);
54408         CHECK_ACCESS(retry_strategy_ptr);
54409         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
54410         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
54411         LDKChannelManager channelmanager_conv;
54412         channelmanager_conv.inner = untag_ptr(channelmanager);
54413         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
54414         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
54415         channelmanager_conv.is_owned = false;
54416         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
54417         *ret_conv = pay_zero_value_invoice_with_id(&invoice_conv, amount_msats, payment_id_ref, retry_strategy_conv, &channelmanager_conv);
54418         return tag_ptr(ret_conv, true);
54419 }
54420
54421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54422         if (!ptr_is_owned(this_ptr)) return;
54423         void* this_ptr_ptr = untag_ptr(this_ptr);
54424         CHECK_ACCESS(this_ptr_ptr);
54425         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
54426         FREE(untag_ptr(this_ptr));
54427         PaymentError_free(this_ptr_conv);
54428 }
54429
54430 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
54431         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
54432         *ret_copy = PaymentError_clone(arg);
54433         int64_t ret_ref = tag_ptr(ret_copy, true);
54434         return ret_ref;
54435 }
54436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54437         LDKPaymentError* arg_conv = (LDKPaymentError*)untag_ptr(arg);
54438         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
54439         return ret_conv;
54440 }
54441
54442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54443         LDKPaymentError* orig_conv = (LDKPaymentError*)untag_ptr(orig);
54444         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
54445         *ret_copy = PaymentError_clone(orig_conv);
54446         int64_t ret_ref = tag_ptr(ret_copy, true);
54447         return ret_ref;
54448 }
54449
54450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
54451         LDKStr a_conv = java_to_owned_str(env, a);
54452         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
54453         *ret_copy = PaymentError_invoice(a_conv);
54454         int64_t ret_ref = tag_ptr(ret_copy, true);
54455         return ret_ref;
54456 }
54457
54458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, jclass a) {
54459         LDKRetryableSendFailure a_conv = LDKRetryableSendFailure_from_java(env, a);
54460         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
54461         *ret_copy = PaymentError_sending(a_conv);
54462         int64_t ret_ref = tag_ptr(ret_copy, true);
54463         return ret_ref;
54464 }
54465
54466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_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) {
54467         void* amt_msat_ptr = untag_ptr(amt_msat);
54468         CHECK_ACCESS(amt_msat_ptr);
54469         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
54470         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
54471         LDKThirtyTwoBytes payment_hash_ref;
54472         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54473         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54474         LDKStr description_conv = java_to_owned_str(env, description);
54475         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
54476         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
54477         if (phantom_route_hints_constr.datalen > 0)
54478                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
54479         else
54480                 phantom_route_hints_constr.data = NULL;
54481         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
54482         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
54483                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
54484                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
54485                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
54486                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
54487                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
54488                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
54489                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
54490         }
54491         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
54492         void* entropy_source_ptr = untag_ptr(entropy_source);
54493         CHECK_ACCESS(entropy_source_ptr);
54494         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
54495         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
54496                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54497                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
54498         }
54499         void* node_signer_ptr = untag_ptr(node_signer);
54500         CHECK_ACCESS(node_signer_ptr);
54501         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
54502         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
54503                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54504                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
54505         }
54506         void* logger_ptr = untag_ptr(logger);
54507         CHECK_ACCESS(logger_ptr);
54508         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
54509         if (logger_conv.free == LDKLogger_JCalls_free) {
54510                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54511                 LDKLogger_JCalls_cloned(&logger_conv);
54512         }
54513         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
54514         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
54515         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
54516         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
54517         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
54518         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
54519         *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);
54520         return tag_ptr(ret_conv, true);
54521 }
54522
54523 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) {
54524         void* amt_msat_ptr = untag_ptr(amt_msat);
54525         CHECK_ACCESS(amt_msat_ptr);
54526         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
54527         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
54528         LDKThirtyTwoBytes payment_hash_ref;
54529         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54530         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54531         LDKSha256 description_hash_conv;
54532         description_hash_conv.inner = untag_ptr(description_hash);
54533         description_hash_conv.is_owned = ptr_is_owned(description_hash);
54534         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
54535         description_hash_conv = Sha256_clone(&description_hash_conv);
54536         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
54537         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
54538         if (phantom_route_hints_constr.datalen > 0)
54539                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
54540         else
54541                 phantom_route_hints_constr.data = NULL;
54542         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
54543         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
54544                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
54545                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
54546                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
54547                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
54548                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
54549                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
54550                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
54551         }
54552         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
54553         void* entropy_source_ptr = untag_ptr(entropy_source);
54554         CHECK_ACCESS(entropy_source_ptr);
54555         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
54556         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
54557                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54558                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
54559         }
54560         void* node_signer_ptr = untag_ptr(node_signer);
54561         CHECK_ACCESS(node_signer_ptr);
54562         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
54563         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
54564                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54565                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
54566         }
54567         void* logger_ptr = untag_ptr(logger);
54568         CHECK_ACCESS(logger_ptr);
54569         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
54570         if (logger_conv.free == LDKLogger_JCalls_free) {
54571                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54572                 LDKLogger_JCalls_cloned(&logger_conv);
54573         }
54574         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
54575         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
54576         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
54577         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
54578         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
54579         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
54580         *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);
54581         return tag_ptr(ret_conv, true);
54582 }
54583
54584 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) {
54585         LDKChannelManager channelmanager_conv;
54586         channelmanager_conv.inner = untag_ptr(channelmanager);
54587         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
54588         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
54589         channelmanager_conv.is_owned = false;
54590         void* node_signer_ptr = untag_ptr(node_signer);
54591         CHECK_ACCESS(node_signer_ptr);
54592         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
54593         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
54594                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54595                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
54596         }
54597         void* logger_ptr = untag_ptr(logger);
54598         CHECK_ACCESS(logger_ptr);
54599         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
54600         if (logger_conv.free == LDKLogger_JCalls_free) {
54601                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54602                 LDKLogger_JCalls_cloned(&logger_conv);
54603         }
54604         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
54605         void* amt_msat_ptr = untag_ptr(amt_msat);
54606         CHECK_ACCESS(amt_msat_ptr);
54607         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
54608         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
54609         LDKStr description_conv = java_to_owned_str(env, description);
54610         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
54611         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
54612         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
54613         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
54614         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
54615         *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);
54616         return tag_ptr(ret_conv, true);
54617 }
54618
54619 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) {
54620         LDKChannelManager channelmanager_conv;
54621         channelmanager_conv.inner = untag_ptr(channelmanager);
54622         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
54623         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
54624         channelmanager_conv.is_owned = false;
54625         void* node_signer_ptr = untag_ptr(node_signer);
54626         CHECK_ACCESS(node_signer_ptr);
54627         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
54628         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
54629                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54630                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
54631         }
54632         void* logger_ptr = untag_ptr(logger);
54633         CHECK_ACCESS(logger_ptr);
54634         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
54635         if (logger_conv.free == LDKLogger_JCalls_free) {
54636                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54637                 LDKLogger_JCalls_cloned(&logger_conv);
54638         }
54639         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
54640         void* amt_msat_ptr = untag_ptr(amt_msat);
54641         CHECK_ACCESS(amt_msat_ptr);
54642         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
54643         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
54644         LDKSha256 description_hash_conv;
54645         description_hash_conv.inner = untag_ptr(description_hash);
54646         description_hash_conv.is_owned = ptr_is_owned(description_hash);
54647         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
54648         description_hash_conv = Sha256_clone(&description_hash_conv);
54649         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
54650         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
54651         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
54652         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
54653         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
54654         *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);
54655         return tag_ptr(ret_conv, true);
54656 }
54657
54658 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) {
54659         LDKChannelManager channelmanager_conv;
54660         channelmanager_conv.inner = untag_ptr(channelmanager);
54661         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
54662         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
54663         channelmanager_conv.is_owned = false;
54664         void* node_signer_ptr = untag_ptr(node_signer);
54665         CHECK_ACCESS(node_signer_ptr);
54666         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
54667         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
54668                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54669                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
54670         }
54671         void* logger_ptr = untag_ptr(logger);
54672         CHECK_ACCESS(logger_ptr);
54673         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
54674         if (logger_conv.free == LDKLogger_JCalls_free) {
54675                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54676                 LDKLogger_JCalls_cloned(&logger_conv);
54677         }
54678         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
54679         void* amt_msat_ptr = untag_ptr(amt_msat);
54680         CHECK_ACCESS(amt_msat_ptr);
54681         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
54682         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
54683         LDKSha256 description_hash_conv;
54684         description_hash_conv.inner = untag_ptr(description_hash);
54685         description_hash_conv.is_owned = ptr_is_owned(description_hash);
54686         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
54687         description_hash_conv = Sha256_clone(&description_hash_conv);
54688         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
54689         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
54690         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
54691         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
54692         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
54693         *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);
54694         return tag_ptr(ret_conv, true);
54695 }
54696
54697 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) {
54698         LDKChannelManager channelmanager_conv;
54699         channelmanager_conv.inner = untag_ptr(channelmanager);
54700         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
54701         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
54702         channelmanager_conv.is_owned = false;
54703         void* node_signer_ptr = untag_ptr(node_signer);
54704         CHECK_ACCESS(node_signer_ptr);
54705         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
54706         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
54707                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54708                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
54709         }
54710         void* logger_ptr = untag_ptr(logger);
54711         CHECK_ACCESS(logger_ptr);
54712         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
54713         if (logger_conv.free == LDKLogger_JCalls_free) {
54714                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54715                 LDKLogger_JCalls_cloned(&logger_conv);
54716         }
54717         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
54718         void* amt_msat_ptr = untag_ptr(amt_msat);
54719         CHECK_ACCESS(amt_msat_ptr);
54720         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
54721         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
54722         LDKStr description_conv = java_to_owned_str(env, description);
54723         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
54724         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
54725         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
54726         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
54727         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
54728         *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);
54729         return tag_ptr(ret_conv, true);
54730 }
54731
54732 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) {
54733         LDKChannelManager channelmanager_conv;
54734         channelmanager_conv.inner = untag_ptr(channelmanager);
54735         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
54736         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
54737         channelmanager_conv.is_owned = false;
54738         void* node_signer_ptr = untag_ptr(node_signer);
54739         CHECK_ACCESS(node_signer_ptr);
54740         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
54741         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
54742                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54743                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
54744         }
54745         void* logger_ptr = untag_ptr(logger);
54746         CHECK_ACCESS(logger_ptr);
54747         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
54748         if (logger_conv.free == LDKLogger_JCalls_free) {
54749                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54750                 LDKLogger_JCalls_cloned(&logger_conv);
54751         }
54752         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
54753         void* amt_msat_ptr = untag_ptr(amt_msat);
54754         CHECK_ACCESS(amt_msat_ptr);
54755         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
54756         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
54757         LDKStr description_conv = java_to_owned_str(env, description);
54758         LDKThirtyTwoBytes payment_hash_ref;
54759         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54760         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54761         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
54762         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
54763         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
54764         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
54765         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
54766         *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);
54767         return tag_ptr(ret_conv, true);
54768 }
54769
54770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
54771         LDKStr s_conv = java_to_owned_str(env, s);
54772         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
54773         *ret_conv = SiPrefix_from_str(s_conv);
54774         return tag_ptr(ret_conv, true);
54775 }
54776
54777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
54778         LDKStr s_conv = java_to_owned_str(env, s);
54779         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
54780         *ret_conv = Invoice_from_str(s_conv);
54781         return tag_ptr(ret_conv, true);
54782 }
54783
54784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
54785         LDKStr s_conv = java_to_owned_str(env, s);
54786         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
54787         *ret_conv = SignedRawInvoice_from_str(s_conv);
54788         return tag_ptr(ret_conv, true);
54789 }
54790
54791 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
54792         LDKParseError* o_conv = (LDKParseError*)untag_ptr(o);
54793         LDKStr ret_str = ParseError_to_str(o_conv);
54794         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
54795         Str_free(ret_str);
54796         return ret_conv;
54797 }
54798
54799 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
54800         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)untag_ptr(o);
54801         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
54802         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
54803         Str_free(ret_str);
54804         return ret_conv;
54805 }
54806
54807 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
54808         LDKInvoice o_conv;
54809         o_conv.inner = untag_ptr(o);
54810         o_conv.is_owned = ptr_is_owned(o);
54811         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
54812         o_conv.is_owned = false;
54813         LDKStr ret_str = Invoice_to_str(&o_conv);
54814         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
54815         Str_free(ret_str);
54816         return ret_conv;
54817 }
54818
54819 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
54820         LDKSignedRawInvoice o_conv;
54821         o_conv.inner = untag_ptr(o);
54822         o_conv.is_owned = ptr_is_owned(o);
54823         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
54824         o_conv.is_owned = false;
54825         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
54826         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
54827         Str_free(ret_str);
54828         return ret_conv;
54829 }
54830
54831 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
54832         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
54833         LDKStr ret_str = Currency_to_str(o_conv);
54834         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
54835         Str_free(ret_str);
54836         return ret_conv;
54837 }
54838
54839 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
54840         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
54841         LDKStr ret_str = SiPrefix_to_str(o_conv);
54842         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
54843         Str_free(ret_str);
54844         return ret_conv;
54845 }
54846
54847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
54848         LDKRapidGossipSync this_obj_conv;
54849         this_obj_conv.inner = untag_ptr(this_obj);
54850         this_obj_conv.is_owned = ptr_is_owned(this_obj);
54851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
54852         RapidGossipSync_free(this_obj_conv);
54853 }
54854
54855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger) {
54856         LDKNetworkGraph network_graph_conv;
54857         network_graph_conv.inner = untag_ptr(network_graph);
54858         network_graph_conv.is_owned = ptr_is_owned(network_graph);
54859         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
54860         network_graph_conv.is_owned = false;
54861         void* logger_ptr = untag_ptr(logger);
54862         CHECK_ACCESS(logger_ptr);
54863         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
54864         if (logger_conv.free == LDKLogger_JCalls_free) {
54865                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
54866                 LDKLogger_JCalls_cloned(&logger_conv);
54867         }
54868         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv, logger_conv);
54869         int64_t ret_ref = 0;
54870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54871         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54872         return ret_ref;
54873 }
54874
54875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1update_1network_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray update_data) {
54876         LDKRapidGossipSync this_arg_conv;
54877         this_arg_conv.inner = untag_ptr(this_arg);
54878         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54880         this_arg_conv.is_owned = false;
54881         LDKu8slice update_data_ref;
54882         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
54883         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
54884         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
54885         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
54886         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
54887         return tag_ptr(ret_conv, true);
54888 }
54889
54890 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) {
54891         LDKRapidGossipSync this_arg_conv;
54892         this_arg_conv.inner = untag_ptr(this_arg);
54893         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54895         this_arg_conv.is_owned = false;
54896         LDKu8slice update_data_ref;
54897         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
54898         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
54899         void* current_time_unix_ptr = untag_ptr(current_time_unix);
54900         CHECK_ACCESS(current_time_unix_ptr);
54901         LDKCOption_u64Z current_time_unix_conv = *(LDKCOption_u64Z*)(current_time_unix_ptr);
54902         current_time_unix_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(current_time_unix));
54903         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
54904         *ret_conv = RapidGossipSync_update_network_graph_no_std(&this_arg_conv, update_data_ref, current_time_unix_conv);
54905         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
54906         return tag_ptr(ret_conv, true);
54907 }
54908
54909 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
54910         LDKRapidGossipSync this_arg_conv;
54911         this_arg_conv.inner = untag_ptr(this_arg);
54912         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54914         this_arg_conv.is_owned = false;
54915         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
54916         return ret_conv;
54917 }
54918
54919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54920         if (!ptr_is_owned(this_ptr)) return;
54921         void* this_ptr_ptr = untag_ptr(this_ptr);
54922         CHECK_ACCESS(this_ptr_ptr);
54923         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
54924         FREE(untag_ptr(this_ptr));
54925         GraphSyncError_free(this_ptr_conv);
54926 }
54927
54928 static inline uint64_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
54929         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
54930         *ret_copy = GraphSyncError_clone(arg);
54931         int64_t ret_ref = tag_ptr(ret_copy, true);
54932         return ret_ref;
54933 }
54934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54935         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)untag_ptr(arg);
54936         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
54937         return ret_conv;
54938 }
54939
54940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54941         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)untag_ptr(orig);
54942         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
54943         *ret_copy = GraphSyncError_clone(orig_conv);
54944         int64_t ret_ref = tag_ptr(ret_copy, true);
54945         return ret_ref;
54946 }
54947
54948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
54949         void* a_ptr = untag_ptr(a);
54950         CHECK_ACCESS(a_ptr);
54951         LDKDecodeError a_conv = *(LDKDecodeError*)(a_ptr);
54952         a_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(a));
54953         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
54954         *ret_copy = GraphSyncError_decode_error(a_conv);
54955         int64_t ret_ref = tag_ptr(ret_copy, true);
54956         return ret_ref;
54957 }
54958
54959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
54960         LDKLightningError a_conv;
54961         a_conv.inner = untag_ptr(a);
54962         a_conv.is_owned = ptr_is_owned(a);
54963         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
54964         a_conv = LightningError_clone(&a_conv);
54965         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
54966         *ret_copy = GraphSyncError_lightning_error(a_conv);
54967         int64_t ret_ref = tag_ptr(ret_copy, true);
54968         return ret_ref;
54969 }
54970